-
Notifications
You must be signed in to change notification settings - Fork 18
/
Account.java
executable file
·79 lines (65 loc) · 2.19 KB
/
Account.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package com.alvazan.test.db;
import java.util.List;
import com.alvazan.orm.api.Index;
import com.alvazan.orm.api.Query;
import com.alvazan.orm.api.anno.Id;
import com.alvazan.orm.api.anno.Indexed;
import com.alvazan.orm.api.anno.NoSqlEntity;
import com.alvazan.orm.api.anno.NoSqlQueries;
import com.alvazan.orm.api.anno.NoSqlQuery;
@NoSqlEntity
@NoSqlQueries({
@NoSqlQuery(name="findBetween", query="select ENTITY b FROM TABLE WHERE b.users >= :from and b.users < :to"),
@NoSqlQuery(name="findAll", query="select ENTITY d FROM TABLE"),
@NoSqlQuery(name="findAnd", query="select ENTITY a FROM TABLE WHERE a.name=:name and a.isActive=:active"),
@NoSqlQuery(name="findOr", query="select ENTITY a FROM TABLE WHERE a.name=:name or a.isActive=:active")
})
public class Account extends AccountSuper{
@Id
private String id;
@Indexed
private String name;
@Indexed
private Float indexedValue;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Float getIndexedValue() {
return indexedValue;
}
public void setIndexedValue(Float users) {
this.indexedValue = users;
}
public static List<Account> findBetween(Index<Account> index, float from, float to) {
Query<Account> query = index.getNamedQuery("findBetween");
query.setParameter("from", from);
query.setParameter("to", to);
return query.getResultList();
}
public static List<Account> findAll(Index<Account> index) {
Query<Account> query = index.getNamedQuery("findAll");
return query.getResultList();
}
public static List<Account> findAnd(Index<Account> index, String name, Boolean active) {
Query<Account> query = index.getNamedQuery("findAnd");
query.setParameter("name", name);
query.setParameter("active", active);
return query.getResultList();
}
public static List<Account> findOr(Index<Account> index, String name,
boolean active) {
Query<Account> query = index.getNamedQuery("findOr");
query.setParameter("name", name);
query.setParameter("active", active);
return query.getResultList();
}
}