Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Help: Multiple simple foreign key annotations for Hibernate(How do I annotate the class file properly for multiple foreign keys?)
Help: Multiple simple foreign key annotations for Hibernate [message #627971] Thu, 23 September 2010 08:08 Go to next message
Robert  is currently offline Robert Friend
Messages: 14
Registered: September 2010
Junior Member
If I have a MySQL database with an Equipment table, a Tool table, and a Hand-Held Tool table (for instance) like this:

(foreign keys are listed for this table)
Equipment Columns:
int pkEquipment
varchar20 nameoftool

Equipment foreign keys:
Tool pkTool
Hand-Held Tool pkHHTool

(these two tables let's say they are just primary keys)
Tool Columns:
int pkTool

Hand-Held Tools Columns:
int pkHHTool

Can anyone explain how to annotate the two foreign keys for the equipment class and seeing the other two classes (in case they have annotation elements in reverse) would be nice as well. Here is the class code so far:

@Entity(name="Equipment")
public class Equipment {
@Id //primary key
@Column(name = "EQUIPMENT_ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
private int equipmentId;

@Column(name="nameoftool", nullable=false, length=25)
private String nameoftool;

...
// foreign key annotations go here
...
}

@Entity(name="Tool")
public class Tool {
@Id //primary key
@Column(name = "TOOL_ID",nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
private int toolId;

...
// any supporting annotation for equipment table? (im guessing no)
...
}

@Entity(name="Hand-Held Tool")
public class HHTool {
@Id //primary key
@Column(name = "HHTOOL_ID",nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
private int hhtoolId;

...
// any supporting annotation for equipment table? (im guessing no)
...
}

[Updated on: Thu, 23 September 2010 08:13]

Report message to a moderator

Re: Help: Multiple simple foreign key annotations for Hibernate [message #628021 is a reply to message #627971] Thu, 23 September 2010 08:48 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
You should ask a hibernate/jpa forum (hibernate.org). JPA implementation
@Eclipse is eclipse.rt.eclipselink

Tom

Am 23.09.10 10:08, schrieb Robert:
> If I have a MySQL database with an Equipment table, a Tool table, and a
> Hand-Held Tool table (for instance) like this:
>
> (foreign keys are listed for this table)
> Equipment Columns: Equipment foreign keys
> int pkEquipment Tool pkTool
> varchar20 nameoftool Hand-Held Tool pkHHTool
>
> (these two tables let's say they dont have any foreign keys)
> Tool Columns Hand-Held Tools Columns
> int pkTool int pkHHTool
>
> Can anyone explain how to annotate the two foreign keys for the
> equipment class and seeing the other two classes (in case they have
> annotation elements in reverse) would be nice as well. Here is the
> class code so far:
>
> @Entity(name="Equipment")
> public class Equipment {
> @Id //primary key
> @Column(name = "EQUIPMENT_ID", nullable = false)
> @GeneratedValue(strategy = GenerationType.AUTO)
> private int equipmentId;
> @Column(name="nameoftool", nullable=false, length=25)
> private String nameoftool;
>
> ...
> // foreign key annotations go here
> ...
> }
>
> @Entity(name="Tool")
> public class Tool {
> @Id //primary key
> @Column(name = "TOOL_ID",nullable = false)
> @GeneratedValue(strategy = GenerationType.AUTO)
> private int toolId;
>
> ...
> // any supporting annotation for equipment table? (im guessing no)
> ...
> }
>
> @Entity(name="Hand-Held Tool")
> public class HHTool {
> @Id //primary key
> @Column(name = "HHTOOL_ID",nullable = false)
> @GeneratedValue(strategy = GenerationType.AUTO)
> private int hhtoolId;
>
> ...
> // any supporting annotation for equipment table? (im guessing no)
> ...
> }
Previous Topic:is there some analysis of eclipse.core
Next Topic:Can not find plug-in id
Goto Forum:
  


Current Time: Fri Apr 26 00:07:36 GMT 2024

Powered by FUDForum. Page generated in 0.02900 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top