-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: CriteriaUpdate - set complex fields
PostPosted: Tue Feb 03, 2015 11:49 am 
Newbie

Joined: Tue Feb 03, 2015 11:38 am
Posts: 1
Hello there,

At first I'd like to to note: I am a newbie in a hibernate world!

So, here is my current problem: I want to update my entities. When I change simple data, such as text or numbers - it works flawless


Code:
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaUpdate<ManualDue> query = cb.createCriteriaUpdate(ManualDue.class);
Root<ManualDue> root = query.from(ManualDue.class);

query.set(ManualDue_.duesValue, cb.sum(root.get(ManualDue_.duesValue),amount));
         
entityManager.createQuery(query).executeUpdate();   


If I try to set some sort of objects, I encounter unexpected issues:

Code:
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaUpdate<ManualDue> query = cb.createCriteriaUpdate(ManualDue.class);
Root<ManualDue> root = query.from(ManualDue.class);

query.set(ManualDue_.unionDuesReason, OrikaUtility.convertObject(mapper, reason, UnionDuesReason.class));
      
entityManager.createQuery(query).executeUpdate();      


17:47:33,863 ERROR ErrorCounter:76 - line 1:133: unexpected token: =
17:47:33,873 ERROR ErrorCounter:71 - line 1:133: unexpected token: =
line 1:133: unexpected token: =
at org.hibernate.hql.internal.antlr.HqlBaseParser.updateStatement(HqlBaseParser.java:251)
....
java.lang.IllegalArgumentException: node to traverse cannot be null!
at org.hibernate.hql.internal.ast.util.NodeTraverser.traverseDepthFirst(NodeTraverser.java:63)
...

What am I doing wrong?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.