Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
浙江兰德纵横网络技术股份有限公司
o2oa
提交
127e4b30
o2oa
项目概览
浙江兰德纵横网络技术股份有限公司
/
o2oa
通知
339
Star
10
Fork
6
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
127e4b30
编写于
6月 01, 2022
作者:
O
o2null
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'fix/fetch' into 'develop'
修正fectch See merge request o2oa/o2oa!675
上级
192b3e29
246c4cc2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
51 deletion
+33
-51
o2server/x_base_core_project/src/main/java/com/x/base/core/container/EntityManagerContainer.java
...ava/com/x/base/core/container/EntityManagerContainer.java
+33
-51
未找到文件。
o2server/x_base_core_project/src/main/java/com/x/base/core/container/EntityManagerContainer.java
浏览文件 @
127e4b30
...
@@ -1017,8 +1017,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1017,8 +1017,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
Root
<
T
>
root
=
cq
.
from
(
cls
);
Root
<
T
>
root
=
cq
.
from
(
cls
);
cq
.
select
(
root
.
get
(
JpaObject
.
id_FIELDNAME
)).
where
(
cb
.
isMember
(
value
,
root
.
get
(
attribute
)));
cq
.
select
(
root
.
get
(
JpaObject
.
id_FIELDNAME
)).
where
(
cb
.
isMember
(
value
,
root
.
get
(
attribute
)));
List
<
String
>
os
=
em
.
createQuery
(
cq
).
getResultList
();
List
<
String
>
os
=
em
.
createQuery
(
cq
).
getResultList
();
List
<
String
>
list
=
new
ArrayList
<>(
os
);
return
new
ArrayList
<>(
os
);
return
list
;
}
}
public
<
T
extends
JpaObject
>
List
<
String
>
idsLessThan
(
Class
<
T
>
cls
,
String
attribute
,
Object
value
)
public
<
T
extends
JpaObject
>
List
<
String
>
idsLessThan
(
Class
<
T
>
cls
,
String
attribute
,
Object
value
)
...
@@ -1063,8 +1062,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1063,8 +1062,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
Predicate
p
=
cb
.
equal
(
root
.
get
(
attribute
),
value
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
attribute
),
value
);
p
=
cb
.
and
(
p
,
cb
.
isMember
(
root
.
get
(
otherAttribute
),
cb
.
literal
(
otherValues
)));
p
=
cb
.
and
(
p
,
cb
.
isMember
(
root
.
get
(
otherAttribute
),
cb
.
literal
(
otherValues
)));
List
<
String
>
os
=
em
.
createQuery
(
cq
.
select
(
root
.
get
(
JpaObject
.
id_FIELDNAME
)).
where
(
p
)).
getResultList
();
List
<
String
>
os
=
em
.
createQuery
(
cq
.
select
(
root
.
get
(
JpaObject
.
id_FIELDNAME
)).
where
(
p
)).
getResultList
();
List
<
String
>
list
=
new
ArrayList
<>(
os
);
return
new
ArrayList
<>(
os
);
return
list
;
}
}
public
void
commit
()
throws
Exception
{
public
void
commit
()
throws
Exception
{
...
@@ -1112,7 +1110,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1112,7 +1110,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
selections
.
add
(
root
.
get
(
str
));
selections
.
add
(
root
.
get
(
str
));
}
}
for
(
Tuple
o
:
em
.
createQuery
(
cq
.
multiselect
(
selections
)).
getResultList
())
{
for
(
Tuple
o
:
em
.
createQuery
(
cq
.
multiselect
(
selections
)).
getResultList
())
{
T
t
=
clz
.
newInstance
();
T
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
attributes
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
attributes
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
}
}
...
@@ -1130,15 +1128,13 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1130,15 +1128,13 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
if
(
StringUtils
.
isEmpty
(
id
))
{
if
(
StringUtils
.
isEmpty
(
id
))
{
return
null
;
return
null
;
}
}
if
(!
attributes
.
contains
(
JpaObject
.
id_FIELDNAME
))
{
List
<
String
>
fields
=
ListTools
.
trim
(
attributes
,
true
,
true
,
JpaObject
.
id_FIELDNAME
);
attributes
.
add
(
JpaObject
.
id_FIELDNAME
);
}
EntityManager
em
=
this
.
get
(
clz
);
EntityManager
em
=
this
.
get
(
clz
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Tuple
>
cq
=
cb
.
createQuery
(
Tuple
.
class
);
CriteriaQuery
<
Tuple
>
cq
=
cb
.
createQuery
(
Tuple
.
class
);
Root
<
T
>
root
=
cq
.
from
(
clz
);
Root
<
T
>
root
=
cq
.
from
(
clz
);
List
<
Selection
<?>>
selections
=
new
ArrayList
<>();
List
<
Selection
<?>>
selections
=
new
ArrayList
<>();
for
(
String
str
:
attribute
s
)
{
for
(
String
str
:
field
s
)
{
selections
.
add
(
root
.
get
(
str
));
selections
.
add
(
root
.
get
(
str
));
}
}
cq
.
multiselect
(
selections
).
where
(
cb
.
equal
(
root
.
get
(
JpaObject
.
id_FIELDNAME
),
id
));
cq
.
multiselect
(
selections
).
where
(
cb
.
equal
(
root
.
get
(
JpaObject
.
id_FIELDNAME
),
id
));
...
@@ -1147,7 +1143,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1147,7 +1143,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
Tuple
tuple
=
list
.
get
(
0
);
Tuple
tuple
=
list
.
get
(
0
);
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
selections
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
selections
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
attribute
s
.
get
(
i
),
tuple
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
field
s
.
get
(
i
),
tuple
.
get
(
selections
.
get
(
i
)));
}
}
}
}
return
t
;
return
t
;
...
@@ -1181,32 +1177,26 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1181,32 +1177,26 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
if
(
ids
.
isEmpty
())
{
if
(
ids
.
isEmpty
())
{
return
list
;
return
list
;
}
}
List
<
String
>
fields
=
ListTools
.
trim
(
attributes
,
true
,
true
,
JpaObject
.
id_FIELDNAME
);
List
<
String
>
idList
=
new
ArrayList
<>(
ids
);
List
<
String
>
idList
=
new
ArrayList
<>(
ids
);
if
(!
attributes
.
contains
(
JpaObject
.
id_FIELDNAME
))
{
attributes
.
add
(
JpaObject
.
id_FIELDNAME
);
}
EntityManager
em
=
this
.
get
(
clz
);
EntityManager
em
=
this
.
get
(
clz
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Tuple
>
cq
=
cb
.
createQuery
(
Tuple
.
class
);
CriteriaQuery
<
Tuple
>
cq
=
cb
.
createQuery
(
Tuple
.
class
);
Root
<
T
>
root
=
cq
.
from
(
clz
);
Root
<
T
>
root
=
cq
.
from
(
clz
);
List
<
Selection
<?>>
selections
=
new
ArrayList
<>();
List
<
Selection
<?>>
selections
=
new
ArrayList
<>();
for
(
String
str
:
attribute
s
)
{
for
(
String
str
:
field
s
)
{
selections
.
add
(
root
.
get
(
str
));
selections
.
add
(
root
.
get
(
str
));
}
}
cq
.
multiselect
(
selections
).
where
(
root
.
get
(
JpaObject
.
id_FIELDNAME
).
in
(
idList
));
cq
.
multiselect
(
selections
).
where
(
root
.
get
(
JpaObject
.
id_FIELDNAME
).
in
(
idList
));
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
T
t
=
clz
.
newInstance
();
T
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
attribute
s
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
field
s
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
attribute
s
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
field
s
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
}
}
list
.
add
(
t
);
list
.
add
(
t
);
}
}
List
<
T
>
ordering
=
new
ArrayList
<>(
list
);
List
<
T
>
ordering
=
new
ArrayList
<>(
list
);
Collections
.
sort
(
ordering
,
new
Comparator
<
T
>()
{
Collections
.
sort
(
ordering
,
(
o1
,
o2
)
->
Integer
.
compare
(
idList
.
indexOf
(
o1
.
getId
()),
idList
.
indexOf
(
o2
.
getId
())));
public
int
compare
(
T
t1
,
T
t2
)
{
return
Integer
.
compare
(
idList
.
indexOf
(
t1
.
getId
()),
idList
.
indexOf
(
t2
.
getId
()));
}
});
return
ordering
;
return
ordering
;
}
}
...
@@ -1242,10 +1232,10 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1242,10 +1232,10 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
}
}
/* 仅在单一数据库可用 */
/* 仅在单一数据库可用 */
public
<
T
extends
JpaObject
,
W
extends
GsonPropertyObject
>
List
<
T
>
fetch
(
Class
<
T
>
clz
,
List
<
String
>
fetchA
ttributes
,
public
<
T
extends
JpaObject
,
W
extends
GsonPropertyObject
>
List
<
T
>
fetch
(
Class
<
T
>
clz
,
List
<
String
>
a
ttributes
,
Predicate
predicate
)
throws
Exception
{
Predicate
predicate
)
throws
Exception
{
List
<
T
>
list
=
new
ArrayList
<>();
List
<
T
>
list
=
new
ArrayList
<>();
List
<
String
>
fields
=
ListTools
.
trim
(
fetchA
ttributes
,
true
,
true
,
JpaObject
.
id_FIELDNAME
);
List
<
String
>
fields
=
ListTools
.
trim
(
a
ttributes
,
true
,
true
,
JpaObject
.
id_FIELDNAME
);
EntityManager
em
=
this
.
get
(
clz
);
EntityManager
em
=
this
.
get
(
clz
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Tuple
>
cq
=
cb
.
createQuery
(
Tuple
.
class
);
CriteriaQuery
<
Tuple
>
cq
=
cb
.
createQuery
(
Tuple
.
class
);
...
@@ -1255,12 +1245,9 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1255,12 +1245,9 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
selections
.
add
(
root
.
get
(
str
));
selections
.
add
(
root
.
get
(
str
));
}
}
cq
.
multiselect
(
selections
).
where
(
predicate
);
cq
.
multiselect
(
selections
).
where
(
predicate
);
// if (StringUtils.isNotEmpty(orderAttribute)) {
// cq.orderBy(cb.desc(root.get(orderAttribute)));
// }
T
t
=
null
;
T
t
=
null
;
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
t
=
clz
.
newInstance
();
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
}
}
...
@@ -1270,8 +1257,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1270,8 +1257,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
}
}
public
<
T
extends
JpaObject
>
List
<
T
>
fetchEqual
(
Class
<
T
>
clz
,
String
attribute
,
Object
value
)
throws
Exception
{
public
<
T
extends
JpaObject
>
List
<
T
>
fetchEqual
(
Class
<
T
>
clz
,
String
attribute
,
Object
value
)
throws
Exception
{
List
<
T
>
os
=
this
.
fetchEqual
(
clz
,
JpaObject
.
singularAttributeField
(
clz
,
true
,
true
),
attribute
,
value
);
return
this
.
fetchEqual
(
clz
,
JpaObject
.
singularAttributeField
(
clz
,
true
,
true
),
attribute
,
value
);
return
os
;
}
}
public
<
T
extends
JpaObject
,
W
extends
GsonPropertyObject
>
List
<
W
>
fetchEqual
(
Class
<
T
>
clz
,
WrapCopier
<
T
,
W
>
copier
,
public
<
T
extends
JpaObject
,
W
extends
GsonPropertyObject
>
List
<
W
>
fetchEqual
(
Class
<
T
>
clz
,
WrapCopier
<
T
,
W
>
copier
,
...
@@ -1295,7 +1281,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1295,7 +1281,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
Predicate
p
=
cb
.
equal
(
root
.
get
(
attribute
),
value
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
attribute
),
value
);
cq
.
multiselect
(
selections
).
where
(
p
);
cq
.
multiselect
(
selections
).
where
(
p
);
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
T
t
=
clz
.
newInstance
();
T
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
}
}
...
@@ -1306,9 +1292,8 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1306,9 +1292,8 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
public
<
T
extends
JpaObject
>
List
<
T
>
fetchEqualAndEqual
(
Class
<
T
>
clz
,
String
attribute
,
Object
value
,
public
<
T
extends
JpaObject
>
List
<
T
>
fetchEqualAndEqual
(
Class
<
T
>
clz
,
String
attribute
,
Object
value
,
String
otherAttribute
,
Object
otherValue
)
throws
Exception
{
String
otherAttribute
,
Object
otherValue
)
throws
Exception
{
List
<
T
>
os
=
this
.
fetchEqualAndEqual
(
clz
,
JpaObject
.
singularAttributeField
(
clz
,
true
,
true
),
attribute
,
value
,
return
this
.
fetchEqualAndEqual
(
clz
,
JpaObject
.
singularAttributeField
(
clz
,
true
,
true
),
attribute
,
value
,
otherAttribute
,
otherValue
);
otherAttribute
,
otherValue
);
return
os
;
}
}
public
<
T
extends
JpaObject
,
W
extends
GsonPropertyObject
>
List
<
W
>
fetchEqualAndEqual
(
Class
<
T
>
clz
,
public
<
T
extends
JpaObject
,
W
extends
GsonPropertyObject
>
List
<
W
>
fetchEqualAndEqual
(
Class
<
T
>
clz
,
...
@@ -1333,7 +1318,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1333,7 +1318,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
Predicate
p
=
cb
.
and
(
cb
.
equal
(
root
.
get
(
attribute
),
value
),
cb
.
equal
(
root
.
get
(
otherAttribute
),
otherValue
));
Predicate
p
=
cb
.
and
(
cb
.
equal
(
root
.
get
(
attribute
),
value
),
cb
.
equal
(
root
.
get
(
otherAttribute
),
otherValue
));
cq
.
multiselect
(
selections
).
where
(
p
);
cq
.
multiselect
(
selections
).
where
(
p
);
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
T
t
=
clz
.
newInstance
();
T
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
}
}
...
@@ -1368,7 +1353,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1368,7 +1353,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
Predicate
p
=
cb
.
or
(
cb
.
isNull
(
root
.
get
(
attribute
)),
cb
.
notEqual
(
root
.
get
(
attribute
),
value
));
Predicate
p
=
cb
.
or
(
cb
.
isNull
(
root
.
get
(
attribute
)),
cb
.
notEqual
(
root
.
get
(
attribute
),
value
));
cq
.
multiselect
(
selections
).
where
(
p
);
cq
.
multiselect
(
selections
).
where
(
p
);
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
T
t
=
clz
.
newInstance
();
T
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
}
}
...
@@ -1379,8 +1364,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1379,8 +1364,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
public
<
T
extends
JpaObject
,
V
extends
Object
>
List
<
T
>
fetchIn
(
Class
<
T
>
clz
,
String
attribute
,
Collection
<
V
>
values
)
public
<
T
extends
JpaObject
,
V
extends
Object
>
List
<
T
>
fetchIn
(
Class
<
T
>
clz
,
String
attribute
,
Collection
<
V
>
values
)
throws
Exception
{
throws
Exception
{
List
<
T
>
os
=
this
.
fetchIn
(
clz
,
JpaObject
.
singularAttributeField
(
clz
,
true
,
true
),
attribute
,
values
);
return
this
.
fetchIn
(
clz
,
JpaObject
.
singularAttributeField
(
clz
,
true
,
true
),
attribute
,
values
);
return
os
;
}
}
public
<
T
extends
JpaObject
,
W
extends
GsonPropertyObject
,
V
extends
Object
>
List
<
W
>
fetchIn
(
Class
<
T
>
clz
,
public
<
T
extends
JpaObject
,
W
extends
GsonPropertyObject
,
V
extends
Object
>
List
<
W
>
fetchIn
(
Class
<
T
>
clz
,
...
@@ -1404,7 +1388,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1404,7 +1388,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
Predicate
p
=
cb
.
isMember
(
root
.
get
(
attribute
),
cb
.
literal
(
values
));
Predicate
p
=
cb
.
isMember
(
root
.
get
(
attribute
),
cb
.
literal
(
values
));
cq
.
multiselect
(
selections
).
where
(
p
);
cq
.
multiselect
(
selections
).
where
(
p
);
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
T
t
=
clz
.
newInstance
();
T
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
}
}
...
@@ -1415,9 +1399,8 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1415,9 +1399,8 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
public
<
T
extends
JpaObject
,
V
extends
Object
>
List
<
T
>
fetchEqualAndIn
(
Class
<
T
>
clz
,
String
attribute
,
Object
value
,
public
<
T
extends
JpaObject
,
V
extends
Object
>
List
<
T
>
fetchEqualAndIn
(
Class
<
T
>
clz
,
String
attribute
,
Object
value
,
String
otherAttribute
,
Collection
<
V
>
otherValues
)
throws
Exception
{
String
otherAttribute
,
Collection
<
V
>
otherValues
)
throws
Exception
{
List
<
T
>
os
=
this
.
fetchEqualAndIn
(
clz
,
JpaObject
.
singularAttributeField
(
clz
,
true
,
true
),
attribute
,
value
,
return
this
.
fetchEqualAndIn
(
clz
,
JpaObject
.
singularAttributeField
(
clz
,
true
,
true
),
attribute
,
value
,
otherAttribute
,
otherValues
);
otherAttribute
,
otherValues
);
return
os
;
}
}
public
<
T
extends
JpaObject
,
W
extends
GsonPropertyObject
,
V
extends
Object
>
List
<
W
>
fetchEqualAndIn
(
Class
<
T
>
clz
,
public
<
T
extends
JpaObject
,
W
extends
GsonPropertyObject
,
V
extends
Object
>
List
<
W
>
fetchEqualAndIn
(
Class
<
T
>
clz
,
...
@@ -1443,7 +1426,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1443,7 +1426,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
cb
.
isMember
(
root
.
get
(
otherAttribute
),
cb
.
literal
(
otherValues
)));
cb
.
isMember
(
root
.
get
(
otherAttribute
),
cb
.
literal
(
otherValues
)));
cq
.
multiselect
(
selections
).
where
(
p
);
cq
.
multiselect
(
selections
).
where
(
p
);
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
T
t
=
clz
.
newInstance
();
T
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
}
}
...
@@ -1478,7 +1461,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1478,7 +1461,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
Predicate
p
=
cb
.
isMember
(
value
,
root
.
get
(
attribute
));
Predicate
p
=
cb
.
isMember
(
value
,
root
.
get
(
attribute
));
cq
.
multiselect
(
selections
).
where
(
p
);
cq
.
multiselect
(
selections
).
where
(
p
);
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
T
t
=
clz
.
newInstance
();
T
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
}
}
...
@@ -1489,9 +1472,8 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1489,9 +1472,8 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
public
<
T
extends
JpaObject
>
List
<
T
>
fetchEuqalOrIsMember
(
Class
<
T
>
clz
,
String
equalAttribute
,
Object
equalValue
,
public
<
T
extends
JpaObject
>
List
<
T
>
fetchEuqalOrIsMember
(
Class
<
T
>
clz
,
String
equalAttribute
,
Object
equalValue
,
String
isMemberAttribute
,
Object
isMemberValue
)
throws
Exception
{
String
isMemberAttribute
,
Object
isMemberValue
)
throws
Exception
{
List
<
T
>
os
=
this
.
fetchEuqalOrIsMember
(
clz
,
JpaObject
.
singularAttributeField
(
clz
,
true
,
true
),
equalAttribute
,
return
this
.
fetchEuqalOrIsMember
(
clz
,
JpaObject
.
singularAttributeField
(
clz
,
true
,
true
),
equalAttribute
,
equalValue
,
isMemberAttribute
,
isMemberValue
);
equalValue
,
isMemberAttribute
,
isMemberValue
);
return
os
;
}
}
public
<
T
extends
JpaObject
,
W
extends
GsonPropertyObject
>
List
<
W
>
fetchEuqalOrIsMember
(
Class
<
T
>
clz
,
public
<
T
extends
JpaObject
,
W
extends
GsonPropertyObject
>
List
<
W
>
fetchEuqalOrIsMember
(
Class
<
T
>
clz
,
...
@@ -1518,7 +1500,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1518,7 +1500,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
p
=
cb
.
or
(
p
,
cb
.
isMember
(
isMemberValue
,
root
.
get
(
isMemberAttribute
)));
p
=
cb
.
or
(
p
,
cb
.
isMember
(
isMemberValue
,
root
.
get
(
isMemberAttribute
)));
cq
.
multiselect
(
selections
).
where
(
p
);
cq
.
multiselect
(
selections
).
where
(
p
);
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
getResultList
())
{
T
t
=
clz
.
newInstance
();
T
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
}
}
...
@@ -1776,7 +1758,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1776,7 +1758,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
cq
.
multiselect
(
selections
).
where
(
predicate
).
orderBy
(
cb
.
desc
(
root
.
get
(
orderAttribute
)));
cq
.
multiselect
(
selections
).
where
(
predicate
).
orderBy
(
cb
.
desc
(
root
.
get
(
orderAttribute
)));
T
t
=
null
;
T
t
=
null
;
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
setFirstResult
(
startPosition
).
setMaxResults
(
max
).
getResultList
())
{
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
setFirstResult
(
startPosition
).
setMaxResults
(
max
).
getResultList
())
{
t
=
clz
.
newInstance
();
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
}
}
...
@@ -1820,7 +1802,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1820,7 +1802,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
cq
.
multiselect
(
selections
).
where
(
predicate
).
orderBy
(
cb
.
asc
(
root
.
get
(
orderAttribute
)));
cq
.
multiselect
(
selections
).
where
(
predicate
).
orderBy
(
cb
.
asc
(
root
.
get
(
orderAttribute
)));
T
t
=
null
;
T
t
=
null
;
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
setFirstResult
(
startPosition
).
setMaxResults
(
max
).
getResultList
())
{
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
setFirstResult
(
startPosition
).
setMaxResults
(
max
).
getResultList
())
{
t
=
clz
.
newInstance
();
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
}
}
...
@@ -1864,7 +1846,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1864,7 +1846,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
Predicate
p
=
cb
.
equal
(
root
.
get
(
equalAttribute
),
equalValue
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
equalAttribute
),
equalValue
);
cq
.
multiselect
(
selections
).
where
(
p
).
orderBy
(
cb
.
asc
(
root
.
get
(
orderAttribute
)));
cq
.
multiselect
(
selections
).
where
(
p
).
orderBy
(
cb
.
asc
(
root
.
get
(
orderAttribute
)));
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
setFirstResult
(
startPosition
).
setMaxResults
(
max
).
getResultList
())
{
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
setFirstResult
(
startPosition
).
setMaxResults
(
max
).
getResultList
())
{
T
t
=
clz
.
newInstance
();
T
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
}
}
...
@@ -1908,7 +1890,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1908,7 +1890,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
Predicate
p
=
cb
.
equal
(
root
.
get
(
equalAttribute
),
equalValue
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
equalAttribute
),
equalValue
);
cq
.
multiselect
(
selections
).
where
(
p
).
orderBy
(
cb
.
desc
(
root
.
get
(
orderAttribute
)));
cq
.
multiselect
(
selections
).
where
(
p
).
orderBy
(
cb
.
desc
(
root
.
get
(
orderAttribute
)));
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
setFirstResult
(
startPosition
).
setMaxResults
(
max
).
getResultList
())
{
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
setFirstResult
(
startPosition
).
setMaxResults
(
max
).
getResultList
())
{
T
t
=
clz
.
newInstance
();
T
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
}
}
...
@@ -1954,7 +1936,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -1954,7 +1936,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
otherEqualAttribute
),
otherEqualValue
));
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
otherEqualAttribute
),
otherEqualValue
));
cq
.
multiselect
(
selections
).
where
(
p
).
orderBy
(
cb
.
desc
(
root
.
get
(
orderAttribute
)));
cq
.
multiselect
(
selections
).
where
(
p
).
orderBy
(
cb
.
desc
(
root
.
get
(
orderAttribute
)));
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
setFirstResult
(
startPosition
).
setMaxResults
(
max
).
getResultList
())
{
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
setFirstResult
(
startPosition
).
setMaxResults
(
max
).
getResultList
())
{
T
t
=
clz
.
newInstance
();
T
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
}
}
...
@@ -2000,7 +1982,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
...
@@ -2000,7 +1982,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
p
=
cb
.
and
(
p
,
cb
.
notEqual
(
root
.
get
(
otherNotEqualAttribute
),
otherNotEqualValue
));
p
=
cb
.
and
(
p
,
cb
.
notEqual
(
root
.
get
(
otherNotEqualAttribute
),
otherNotEqualValue
));
cq
.
multiselect
(
selections
).
where
(
p
).
orderBy
(
cb
.
desc
(
root
.
get
(
orderAttribute
)));
cq
.
multiselect
(
selections
).
where
(
p
).
orderBy
(
cb
.
desc
(
root
.
get
(
orderAttribute
)));
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
setFirstResult
(
startPosition
).
setMaxResults
(
max
).
getResultList
())
{
for
(
Tuple
o
:
em
.
createQuery
(
cq
).
setFirstResult
(
startPosition
).
setMaxResults
(
max
).
getResultList
())
{
T
t
=
clz
.
newInstance
();
T
t
=
clz
.
getDeclaredConstructor
().
newInstance
();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
PropertyUtils
.
setProperty
(
t
,
fields
.
get
(
i
),
o
.
get
(
selections
.
get
(
i
)));
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录