-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Inheritance + Composite Primary Keys
PostPosted: Fri Jan 04, 2008 7:58 am 
Newbie

Joined: Thu Jul 26, 2007 5:12 am
Posts: 14
Location: Nepal
Code:
@Entity
public class Company
        implements Serializable
{

  @Id
  private Long id;

  @Column(nullable = false, unique=true)
  private String name; 

  public Company()
  {
  }
  getter .. setter...
}



@Embeddable
public class Apk
        implements Serializable
{

  @ManyToOne(optional = false)
  private Company company;

  @NotNull
  @Column(nullable = false)
  private Long id;

  public Apk()
  {
  }
  getters.. setter...
}


@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class A
        implements Serializable
{

  @Id
  private Apk id;
  private String jpt;
 
  public A()
  {
  }
}


@Entity
@DiscriminatorValue(value="B")
public class B
        extends A
        implements Serializable
{
 
  public B()
  {
  }
}



whats wrong with my code??? it throws
org.hibernate.MappingException: Foreign key (FK42C56CD972:B [id])) must have same number of columns as the referenced primary key (A [company_id,id])

_________________
:: there are 10 types of people in this world...1 who understands binary and the other 1 who does not ::


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 05, 2008 12:03 pm 
Newbie

Joined: Thu Jul 26, 2007 5:12 am
Posts: 14
Location: Nepal
I even tried @PrimaryKeyJoinColumn
im lost!!!

_________________
:: there are 10 types of people in this world...1 who understands binary and the other 1 who does not ::


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.