I don't understand everything you're doing, but I just tried to store two entities with the same id, and it didn't work the second time...
The entity class :
Code:
public class Employee
{
private String id;
private String name;
private String firstName;
public Employee(String id, String name, String firstName)
{
this.id = id;
this.name = name;
this.firstName = firstName;
}
...
//getters and setters
}
The mapping :
Code:
<hibernate-mapping package="fr.mipih.duplicate">
<class name="Employee">
<id name="id">
<generator class="assigned" />
</id>
<property name="name" />
<property name="firstName" />
</class>
</hibernate-mapping>
Then I did :
Code:
public static void main(String[] args)
{
Session s = HibernateUtil.currentSession();
s.beginTransaction();
Employee e = new Employee("1","Bat","Mat");
s.save(e);
s.getTransaction().commit();
s.close();
}
If I call this code twice, I receive :
Code:
Exception in thread "main" org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:988)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:337)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at fr.mipih.duplicate.TestDuplicate.main(TestDuplicate.java:21)
Caused by: java.sql.BatchUpdateException: failed batch
at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
... 8 more
So it works fine (obviously, because if not, I would be very concerned about the consistence of Oracle...).
You say you don't get any exception while trying to do that. So what is in your db after your calls finish ? Are you sure the exception is not thrown ? Maybe you simply redirected System.err somewhere you don't see inadvertently ?