[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-3218) ManyToOne Persisting Cascade in Embeddable

Gail Badner (JIRA) noreply at atlassian.com
Fri Jan 21 23:10:05 EST 2011


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3218?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gail Badner updated HHH-3218:
-----------------------------

    Affects Version/s: 3.5.1

> ManyToOne Persisting Cascade in Embeddable
> ------------------------------------------
>
>                 Key: HHH-3218
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3218
>             Project: Hibernate Core
>          Issue Type: Bug
>    Affects Versions: 3.2.6, 3.5.1
>         Environment: Java version:
> java version "1.6.0_04"
> Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
> Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
> Oracle Version:
> Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
> PL/SQL Release 9.2.0.8.0 - Production
> "CORE	9.2.0.8.0	Production"
> TNS for Linux: Version 9.2.0.8.0 - Production
> NLSRTL Version 9.2.0.8.0 - Production
> hibernate: 3.2.6.ga
> hibernate-annotations: 3.3.1.ga
> hibernate-commons-annotations: 3.3.0.ga
> hibernate-entitymanager: 3.3.1.ga
>            Reporter: Endre Jeges
>         Attachments: pairTest.zip
>
>
> Hello,
> I have found something that is a bit strange. For @ManyToOne association properties in an @Embeddable class the cascade PERSIST, SAVE-UPDATE option is not  working well (not sure for the other cascade types), if the entities associated with ManyToOne are transient. I have created a unit test to check it and I have it attached to this issue. It is a maven2 project, and needs Oracle to run it. If I save the associated entites, then everything works fine, also the data structure is created well.
> I have checked the forums and found similar problems, maybe they can help more then my post:
> http://forum.hibernate.org/viewtopic.php?t=965238
> http://forum.hibernate.org/viewtopic.php?t=976534
> http://forum.hibernate.org/viewtopic.php?t=978112
> http://forum.hibernate.org/viewtopic.php?t=978138
> http://forum.hibernate.org/viewtopic.php?t=983766
> http://forum.hibernate.org/viewtopic.php?t=983780
> http://forum.hibernate.org/viewtopic.php?t=983868
> Details:
> @Entity
> class CodedPairHolder {
> 	@Id
> 	private Long id;
> 	@Column(name = "CODE", nullable = false, unique = true, updatable = false, length = 256)
> 	private String code;
> 	@CollectionOfElements
> 	@JoinTable(name = "CODED_PAIR_HOLDER_PAIR_SET", joinColumns = @JoinColumn(name = "CODED_PAIR_HOLDER_ID"))
> 	private final Set<PersonPair> pairs = new HashSet<PersonPair>(0);
>         
>         ........ constructors getters equals hashCode
> }
> @Embeddable
> class PersonPair {
> 	@ManyToOne(optional = false, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
> 	@Cascade( { org.hibernate.annotations.CascadeType.PERSIST, org.hibernate.annotations.CascadeType.MERGE, org.hibernate.annotations.CascadeType.REFRESH,
> 			org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.REPLICATE, org.hibernate.annotations.CascadeType.EVICT })
> 	@JoinColumn(name = "LEFT_PERSON_ID", nullable = false, updatable = false)
> 	private Person left;
> 	@ManyToOne(optional = false, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
> 	@Cascade( { org.hibernate.annotations.CascadeType.PERSIST, org.hibernate.annotations.CascadeType.MERGE, org.hibernate.annotations.CascadeType.REFRESH,
> 			org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.REPLICATE, org.hibernate.annotations.CascadeType.EVICT })
> 	@JoinColumn(name = "RIGHT_PERSON_ID", nullable = false, updatable = false)
> 	private Person right;
>         ........ constructors getters equals hashCode
> }
> @Entity
> class Person {
> 	@Id
> 	private Long id;
> 	@Column(name = "NAME", nullable = false, unique = true, updatable = false, length = 256)
> 	private String name;
>         ........ constructors getters equals hashCode
> }
> The error message is:
> org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: Person
> Regards,
>    jeges

-- 
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