Tuesday 15 January 2013

Modelling a temporal-style relational table in Hibernate -


I am trying to wrap the hibernate around an existing data model, which is expected to fluctuate.

My current sticking point is that the unit is a semi-floating model from the table; No rows are ever destroyed or updated; Instead, the "is_current" column is set to false (and a new line is created with new fields in the update with another primary key).

Being relatively new to hibernate, how do I do this model, or even find out if it's possible that everyone at all Well, a custom @SQLDelete is easy enough to be deleted with annotation, but this update which seems difficult seems theoretically it seems that might be There are clear complexities (the fact that this syntax is not in existence), partial As a matter of fact, to make the primary key worthless between two statements around this fact I will be required and will be updated in the other, and I am convinced that other data sustainability issues have not yet been accepted.

Is there a realistic way to manage it, i.e. deleting model updates + into hibernate?

EDIT: Just to clarify, I know that I can explicitly specify it by inserting SQL to work it in a brute-force way, and then updating I am using the above snippet (with legal references of SQL stents) for However, I really do not want to do this because I am happy with SIL Hibernate that I choose to be born by default for inserts, and hand writing will be very brittle because the orbit changes should be at all. This is a last ditch solution through which it can be applied, but it seems that the point of ORM mapper has to be reduced to a lesser extent if I have to handwrite it to SQL ...

Double edit: Above above will also not work as it is because I have to specify the primary key bind parameter twice in SQL (not possible with question mark), and I should be in hibernation Do not SequenceGenerator to persuade So it seems that I need a programmatic approach here, rather than a configuration - unless I remember some particularly relevant config elements.

You say that no row has been updated, but it seems that you Updating is_current columns, instead of trying to write a custom delete function, there is actually an update, I'm using the same thing to be hibernate (line update, then create a new row).

  row1 setCurrent (wrong); Session.saveOrUpdate (ROW1); Line 2 = new line (line1); // copy constructor; Use a separate primary key (or your default primary key for a new object) line 2. setCurrent (true); Row2.setFoo ("bar"); // Update whatever data you are making to the new line session (line 2);  

You can wrap this process in some medium level / business logic code, to ensure that no other fields are updated.


No comments:

Post a Comment