aspose file tools*
The moose likes Object Relational Mapping and the fly likes updating two tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "updating two tables" Watch "updating two tables" New topic
Author

updating two tables

maganti suryanarayana
Ranch Hand

Joined: Mar 30, 2010
Posts: 53

Hi all,

I want to update two tables using hibernate query which modifies a common column in both the tables. I would like to write the query in hibernate without using update statement. I want to use select statement which is equal to update statement.

Thanks & Regards
Surya


surya
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Select statements select things, they don't update things. Update statements update tables.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1680
    
    7

You can write a select statement to select an entity. When you make changes to that entity the provider will detect that the entity is dirty (has been changed) and when the transaction commits the persistence provider will generate an update statement for you to update the table. But in the end whether you write it or it is generated by the persistence provider Bear is 100% correct it is an update statement that updates the table. I would recommend learning fundamentals first before tackling an ORM as some of this may be hidden from you and might seem confusing. If you are using hibernate you can configure it to output the SQL it generates which will help you to see what is actually happening.

The important take away is that the following statement is not correct.
I want to use select statement which is equal to update statement.


[How To Ask Questions][Read before you PM me]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: updating two tables