Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

CascadeType.ALL is causing Unique key constraint violation exception  RSS feed

Ramesh Krishna
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am having trouble while inserting nodes using JPA with the following mapping.

I am using Hibernate JPA 2.0 and the persistance.xml is like the below

<persistence-unit name="ecc" transaction-type="JTA">

<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.transaction.manager_lookup_class" value ="org.hibernate.transaction.WebSphereExtendedJTATransactionLookup"/>
<property name="transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" />

I have Master entity and child entity with oneToMany relation like below.

@OneToMany(mappedBy = "userPreference", fetch=FetchType.EAGER)

When i process the request then it was trying to do two insert statements(according to hibernate logger statements) for the same and getting exception the unique key violation exception.

Please help me.


It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!