Hi All,

I'm working with entity beans, and I've run into a problem with accessing 
foreign keys that I cannot figure out for the life of me.  The error I'm 
getting is:

08:35:36,962 ERROR [SchemaUpdate] Unsuccessful: create table cats_dogs (cats 
tinyblob not null, dogs tinyblob not null, primary key (dogs))
  | 08:35:36,963 ERROR [SchemaUpdate] BLOB/TEXT column 'dogs' used in key 
specification without a key length

I appreciate your help!! I am using JBoss 4.0.4.CR2 with EJB 3.0 RC5 and Mysql 
5 is my datasource.

Below is the listing of the problem.

I have three entity beans.  Two beans are straight forward.  If I deploy these 
two beans by themselves, everything works fine.  The third uses @ManyToOne to 
access the primary keys of the first two beans, and set them as it's own 
primary keys.  This is where the above problem occurs.

Here is the first straight forward entity bean:

  | @Entity
  | @Table(name = "cats")
  | public class Cats implements Serializable
  | {
  |   private int id;
  |   private String name;
  |   private String description;
  |   
  |   public Cats() {}
  |   
  |   public Cats(String name,String description)
  |   {
  |     this.name = name;
  |     this.description = description;
  |   }
  |   
  |   @Id
  |   @GeneratedValue
  |   public int getId () 
  |   {
  |     return id;
  |   }
  | 
  |   public void setId (int id) 
  |   {
  |     this.id = id;
  |   }
  |   
  |   public String getDescription()
  |   {
  |     return description;
  |   }
  |   
  |   public void setDescription(String description)
  |   {
  |     this.description = description;
  |   }
  |   
  |   public String getName()
  |   {
  |     return name;
  |   }
  | 
  |   public void setName(String name)
  |   {
  |     this.name = name;
  |   }
  |   
  | }

Here's the other straight forward entity bean:


  | @Entity
  | @Table(name = "dogs")
  | public class Dogs implements Serializable
  | {
  |   private int id;
  |   private String name;
  | 
  |   // DogType is an enumeration
  |   private DogType type;
  | 
  |   private int distance;
  |   private String description;
  |   
  |   public Dogs() {}
  |   
  |   public Dogs(String name, DogType type, int distance, String description)
  |   {
  |     this.name = name;
  |     this.type = type;
  |     this.distance = distance;
  |     this.description = description;
  |   }
  | 
  |   public String getDescription()
  |   {
  |     return description;
  |   }
  | 
  |   public void setDescription(String description)
  |   {
  |     this.description = description;
  |   }
  | 
  |   public int getDistance()
  |   {
  |     return distance;
  |   }
  | 
  |   public void setDistance(int distance)
  |   {
  |     this.distance = distance;
  |   }
  | 
  |   @Id
  |   @GeneratedValue
  |   public int getId()
  |   {
  |     return id;
  |   }
  | 
  |   public void setId(int id)
  |   {
  |     this.id = id;
  |   }
  | 
  |   public String getName()
  |   {
  |     return name;
  |   }
  | 
  |   public void setName(String name)
  |   {
  |     this.name = name;
  |   }
  | 
  |   public DogType getType()
  |   {
  |     return type;
  |   }
  | 
  |   public void setType(DogType type)
  |   {
  |     this.type = type;
  |   }
  |   
  | }
  | 

The entity bean with the problem is the following:


  | 
  | @Entity
  | @Table(name = "cats_dogs")
  | public class CatsDogs implements Serializable
  | {
  |   private Cats cats;
  |   private Dogs dogs;
  |   
  |   public CatsDogs() {}
  |   
  |   public CatsDogs(Cats cats, Dogs dogs)
  |   {
  |     this.cats = cats;
  |     this.dogs = dogs;
  |   }
  | 
  |   
  |   @Id
  |   @ManyToOne
  |   @JoinColumn(name="cats_id",referencedColumnName="id")
  |   public Cats getCats()
  |   {
  |     return cats;
  |   }
  | 
  |   public void setCats(Cats cats)
  |   {
  |     this.cats = cats;
  |   }
  | 
  |   @Id
  |   @ManyToOne
  |   @JoinColumn(name="dogs_id",referencedColumnName="id")
  |   public Dogs getDogs()
  |   {
  |     return dogs;
  |   }
  | 
  |   public void setDogs(Dogs dogs)
  |   {
  |     this.dogs = dogs;
  |   }
  | 
  | }
  | 
  | 
  | 

Thanks in advance!!!

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3937195#3937195

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3937195


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to