Announcement Announcement Module
Collapse
No announcement yet.
Hibernate & Annotations & Spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate & Annotations & Spring

    Hi,

    I have a problem, I don't know exactly if it's a hibernate or a spring problem:

    I have 2 tables:
    FirstTable
    • FirstTablePK(PK)
    • Name
    SecondTable
    • FirstTablePK(FK)(PK)
    • SecondTablePK(PK)
    • Name

    and 2 classes to map the tables:

    Class1:
    Code:
    @Entity
    @Table(name="FirstTable")
    public class FirstClass implements Serializable{
       @Id
       @Column(name="FirstTablePK")
       @Type(type="integer")
       private Integer id;
    
       @Column(name="Name")
       @Type(type="string")
       private String name;
    }
    Class2:
    Code:
    @Entity
    @Table(name="SecondTable)
    public class SecondClass implements Serializable{
       @Id
       private SecondTablePK id;
    
       @Column(name="Name")
       @Type(type="string")
       private String name;
    
       @Embeddable
       public class SecondTablePK implements Serializable{
          public SecondTablePK(){}
          @Column(name="SecondTablePK")
          private Integer id;
          @ManyToOne
          @JoinColumn(name="FirstTablePK")
          private FirstClass firstClassImpl.
       }
    }
    When I try to run this I get the following exception:
    org.springframework.orm.hibernate3.HibernateSystem Exception: SecondClass$SecondTablePK; nested exception is org.hibernate.InstantiationException: No default constructor for entity: SecondClass$SecondTablePK
    although I have a default constructor....

    Any ideas...?
    Last edited by orribl; Aug 7th, 2007, 09:00 AM.
Working...
X