dictionary - jpa 2 criteria with map key and value -


in entity have field

@elementcollection @collectiontable @mapkeycolumn(name = "server_id") @column(name = "is_sync") private map<string, boolean> serversyncs = new hashmap<>(); 

i'm trying entities of table not have entry key equals "serverid" (passed parameter in function) or have entry value false.

this i've done now

criteriabuilder builder = session.getcriteriabuilder(); criteriaquery<t> criteriaquery = builder.createquery(clazz); root<t> root = criteriaquery.from(clazz); mapjoin<t, string, boolean> maproot = root.joinmap("serversyncs");  list<t> result = session.createquery(         criteriaquery.where(                 builder.or(                         maproot.isnull(),                         builder.not(maproot.key().in(serverid)),                         builder.and(                                 maproot.key().in(serverid),                                 maproot.value().in(false)                         )                 )         ) ).list(); 

the thing error on query

could not locate collectionpersister role : ca.tecsar.core.model.abstractserverentity.serversyncs

question : how can achieve want jpa 2.0 criteria?

example of need retrieve

id|server_id|is_sync
1|0000000001|true
1|0000000002|false
2|0000000003|false

if ask server_id = 3,i should entity 1 , 2
if ask server_id = 2,i should entity 1
if ask server_id = 1,i should nothing

so couldn't jpa 2 criteria i've succeeded sql query. have table named punch , map table punch_serversyncs.

select p.punchid punch p left join punch_serversyncs pss on p.punchid = pss.punch_punchid (pss.is_sync = false , pss.server_id = 'server2') or not exists (select p.punchid punch_serversyncs pss2  pss2.punch_punchid = p.punchid , pss2.server_id = 'server2') group p.punchid 

Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -