[hibernate-issues] [Hibernate-JIRA] Commented: (ANN-609) Need a way to specify "unsaved-value" strategy using annotations

Emmanuel Bernard (JIRA) noreply at atlassian.com
Sat May 5 11:15:04 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-609?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_26855 ] 

Emmanuel Bernard commented on ANN-609:
--------------------------------------

The reason why I haven't implemented that annotation is that unsaved-value should not be necessary in Hibernate3, it's more legacy than anything else.
If you use saveOrUpdate or merge, Hibernate will "know" if your object needs to be saved or updated even if the strategy is assigned,

> Need a way to specify "unsaved-value" strategy using annotations
> ----------------------------------------------------------------
>
>                 Key: ANN-609
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-609
>             Project: Hibernate Annotations
>          Issue Type: New Feature
>         Environment: Hibernate 3.2.2, Hibernate-annotations 3.2.1
>            Reporter: Suji Suresh
>            Priority: Minor
>
> Hibernate has two ways of specifying a value for primary key:
> 1. Assign a value before handing it over to Hibernate
> 2. Have Hibernate generate the value before persisting
> In my project I have objects of both of the above specified types. In other words I assign value for the primary key for some the objects (lets call these objects "assigned") and for others I have Hibernate generate the value before persisting (lets call these objects "generated"). Since Hibernate annotations does not support "unsaved-value", I do not have a way of specifying "unsaved-value" strategy. While my "generated" objects work perfectly with Hibernate's default "unsaved-value" strategy, I see wrong (but expected) behaviour when I try to persist an "assigned" object that is already present in the database in that, I get StaleStateException instead of DataIntegrityViolationException

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list