I have a 'one-to-many' relationship between the class NotaPedido (one) and ItemNotaPedido (many). Both classes have id generator class = increment.
When i have an empty database, and i save the pojo NotaPedido with its childs ItemNotaPedido, that work OK.
But, when i want to save a second Pojo hibernate give me an Exception.
I think that my problem is that the generator id 'incremente' oj my clid class don't work correctly.
Hibernate version: 2.1.6
Mapping documents:
In the side 'one' of de relationship:
<list
name="lnkItemNotaPedido"
lazy="true"
inverse="false"
cascade="all"
>
<key
column="codigoNotaPedido"
>
</key>
<index
column="codigo"
/>
<one-to-many
class="com.grupoBazar.genesis.ventas.notaPedido.ItemNotaPedido"
/>
</list>
In de side 'many' of the relationship
<class
name="com.grupoBazar.genesis.ventas.notaPedido.ItemNotaPedido"
table="ItemNotaPedido"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="codigo"
column="codigo"
type="long"
>
<generator class="increment">
</generator>
</id>
Code between sessionFactory.openSession() and session.close():
public void insertar(Serializable notaPedido){
Session aSession = getSession();
Transaction tx = null;
try {
tx = aSession.beginTransaction();
aSession.save(notaPedido);
tx.commit();
} catch (HibernateException e) {
LOG.error("Ocurrio un error actualizando el objeto: " + (char)operacion, e);
if (tx != null) {
try {
tx.rollback();
} catch (HibernateException e1) {
LOG.fatal("No se pudo hacer rollback de la transacci
|