Hi, I amgetting this exception when I try to persist an Address object which contains a list of Person objects. I took the id as assigned for both the objects. Still I am getting the violation of unique constraint exception as follows: org.hibernate.exception.ConstraintViolationException: could not insert collection: [test.Address.persons#3001] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1058)
The mappings are: <?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
Sai, can you repost you mappings with CODE tags surround them so that the indentation of the xml remains. It is very difficult to read without those indentations. You will not be able to edit your message, because the < and > signs will be translated to < and >.
Be a little careful with the link that Rashid posted, while most of it is a good example to see, there are a couple bad practices in there, including probably wanting to use try catches around your unit of works.