-->
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.  [ 6 posts ] 
Author Message
 Post subject: Table updates - hibernate the right tool?
PostPosted: Thu Mar 02, 2006 2:04 pm 
Beginner
Beginner

Joined: Thu Feb 17, 2005 6:04 pm
Posts: 23
Hello,

I have a basic entry-level question regarding hibernate table updates, and hibernate's applicability to this situation.

Basically we have a client-side application (non-web) that communicates limited information (say 2 of 50 table fields) to the server, which is then supposed to update the user record with those limited fields.

I haven't found a way to "just update 2 fields" without first SELECTint the row on the server, updating the values, then saving the field.

Is there a way for me to do this? We don't want to transmit then entire user record (user object) from client to server for bandwidth savings.

Thanks,

Mal.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 3:00 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
hibernate is perfectly capable of running sql or hql statements along the lines of "update object set ..." which do nothing but fire off update statements to the db.

this will make the data in-memory out of sync though with the database

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 3:46 pm 
Beginner
Beginner

Joined: Thu Feb 17, 2005 6:04 pm
Posts: 23
Hmm, if I can do that with HQL, then I would consider my problem solved. Can you point me in the right direction on where to look? I thought HQL was centered around correct mapping between the primary cache level in memory and the database, which as you point out, would be out of sync ( I think so anyhow! ).

Thanks,

Mal.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 4:00 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
malachii wrote:
Hmm, if I can do that with HQL, then I would consider my problem solved. Can you point me in the right direction on where to look? I thought HQL was centered around correct mapping between the primary cache level in memory and the database, which as you point out, would be out of sync ( I think so anyhow! ).

Thanks,

Mal.


nope. HQL is a SQL abstraction language. You can write HQL queries just like SQL queries.

Hibernate requires however that you create mapping files for the tables in your database.

If all you're doing is updating tables, then Hibernate is not the correct tool for you. Basic JDBC would suffice.


link to configuration, mapping file, and HQL
http://www.hibernate.org/hib_docs/v3/reference/en/html/

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 4:05 pm 
Beginner
Beginner

Joined: Thu Feb 17, 2005 6:04 pm
Posts: 23
No we're not just updating tables, but it is one of the operations that we do. One (partial) reason for using hibernate is the DB abstraction it provides as our business model requires frequent/easy portability. I knew I could use SQL with hibernate to do those few updates (necessary for performance), but didn't want to get into native-specific code. Hopefully HQL can help us abstract that. We already have the HQL mapping files created and working really well. Just didn't know if the updates could be done the way we wanted.

I'll try some HQL-based updates which will use our mapping files. Interesting. Didn't know we could do this.

Thanks,

Mal.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 4:14 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
here is the link to the update syntax

http://www.hibernate.org/hib_docs/v3/re ... tch-direct

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


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

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.