-->
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: update question
PostPosted: Wed Aug 27, 2008 5:17 am 
Beginner
Beginner

Joined: Thu Jun 14, 2007 4:33 am
Posts: 39
Hi,

ive mapped this class:

Code:
class myclass {
private integer id;
private integer left ;
private integer right ;

public myclass() {}

//here only getter for the fields
getleft, getright, getid.

}


via field injection. a service passes instances of this class to the frontend and i dont want the frontend to be able to modify those properties.

now i have my dao that does something like a clean up. it checks for all records in my myclass-table if valid values for left and right are set.

now because i cant access left and righto i thought i could write a hsql that modifies the columns in the db directly:
Code:
int erg = session.createQuery("update myclass " +
                            "set left = " + leftvalue +
                            ", right = " + rightvalue +
                            " where id = " +  theid).executeUpdate();*/


which actually works (the log shows the sql-statements). but after that i cant retrieve the modified records from the db. the fields of the objects remain null.

the log:
Code:
2008-08-27 10:01:09,745 [main] DEBUG testing.Tester - store a new record
Hibernate: select nextval ('dwh_dev.hibernate_sequence')
Hibernate: insert into dwh_dev.MYCLASS (L, R, parent, ID) values (?, ?, ?, ?)
2008-08-27 10:01:09,925 [main] DEBUG testing.Tester - now do the cleanup
Hibernate: select myclass0_.ID as col_0_0_ from dwh_dev.MYCLASS myclass0_ where myclass0_.parent is null
Hibernate: select myclass0_.ID as col_0_0_ from dwh_dev.MYCLASS myclass0_ where myclass0_.parent=1
[b]Hibernate: update dwh_dev.MYCLASS set l=1, r=2 where ID=1
2008-08-27 10:01:10,185 [main] DEBUG testing.Tester - now get the record from d[/b]b
Hibernate: select myclass0_.ID as ID0_, myclass0_.L as L0_, myclass0_.R as R0_, myclass0_.parent as parent0_ from dwh_dev.MYCLASS myclass0_ where myclass0_.ID=1
2008-08-27 10:01:10,210 [main] DEBUG testing.Tester - now show the properties of the retrieved object: left=null:right=null


if i get the columns via session.createSQLQuery("select left, right from ... ") the columns are updated. only the hsql doesnt update my instances. whats the matter of this behavior?

this piece of code instead of the above update works fine:
Code:
MyClass m = this.findById(theId, false);
                    m.setLeft(left);
                    m.setRight(
                    this.makePersistent(m);

but as you can see i have to provide setter for left and right..


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.