Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: "null id generated" HibernateSystemException
PostPosted: Tue Mar 20, 2012 2:11 pm 
Newbie

Joined: Tue Mar 20, 2012 2:02 pm
Posts: 1
Nabend zusammen,

ich nutze Hibernate mit SpringDataJPA und bekomme den Fehler "null id generated" und es ist eine HibernateSystemException.
Der Fehler tritt auf, wenn ich eine Entity mit 2 Primärschlüssel (id ist autogenerated und revision wird manuell gesetzt) persistent zu speichern. In der Datenbank wird der Primärschlüssel von id generiert und gespeichert, aber in Hibernate bekomme ich ihn nicht zurück.

Relevanter Code:
Code:
@Entity
@AssociationOverrides({
   @AssociationOverride(name = "car.id", joinColumns = @JoinColumn(name = "id")),
   @AssociationOverride(name = "car.revision", joinColumns = @JoinColumn(name = "revision"))
                })
public class Car implements Serializable
{
   private static final long      serialVersionUID   = -3225046848847754211L;

   @EmbeddedId
   private CarPk   carPk;

   //..

   @Override
   public int hashCode()
   {
      //..
   }

   @Override
   public boolean equals(final Object obj)
   {
      //..
   }
}



@Embeddable
public class CarPk implements Serializable
{
   @GeneratedValue(strategy = GenerationType.AUTO)
   private Long   id;
   private Long   revision;

   public CarPk()
   {

   }

   public CarPk(final Long id, final Long revision)
   {
      this.id = id;
      this.revision = revision;
   }

   // ..

   @Override
   public int hashCode()
   {
      // ..
   }

   @Override
   public boolean equals(final Object obj)
   {
      // ..
   }
}

Fehler:
Quote:
...
Caused by: org.hibernate.id.IdentifierGenerationException: null id generated for:class com.car
...


Danke für eure Mühe

Grüße
René


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.