How to use Version Property in Hibernate or Nhibernate

O

orientphoebus

I have a table with columns like this:
----------------------------------------------
Id number not null,
Name VARCHAR2(100) not null,
Update_DT DateTime not null
----------------------------------------------
The Update_DT is used, so that the table can keep all the history
versions of the data.

I want to use Hibernate to get data from this table by a simple
Session.Load(), but I'd like to get the latest version always.

In the hbm.xml, I notice there are <version> and <vimestamp>
properties, which have the similar meaning.

How can I use Session.Load() to load the latest record into Object?

Any similar simple solution will help.

Thanks
 
M

Michael Borgwardt

orientphoebus said:
I have a table with columns like this:
----------------------------------------------
Id number not null,
Name VARCHAR2(100) not null,
Update_DT DateTime not null
----------------------------------------------
The Update_DT is used, so that the table can keep all the history
versions of the data.

I want to use Hibernate to get data from this table by a simple
Session.Load(), but I'd like to get the latest version always.

In the hbm.xml, I notice there are <version> and <vimestamp>
properties, which have the similar meaning.

No, they have a completely different meaning. There are no different
versions of one data item in the DB. They only allow you to spot
concurrent updates while not requiring transactions to span user
interaction.
How can I use Session.Load() to load the latest record into Object?

You'll have to do a query that asks for the row with the maximal
timestamp.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top