G
Guest
Gast
Two tables INTERPRETER_IMAGE AND INTERPRETER_DATA are related to one table INTERPRETER. If a entity bean Interpreter with new entities Interpreter_image and Interpreter_data in a persist() method call, it should automatically be wired between entities. But my program didn't work.
Entity
Select Statement
I hope you find my mistake.
Manu
Entity
Code:
@Entity
@Table(name="INTERPRETER")
public class Interpreter implements Serializable
{
private static final long serialVersionUID = 1;
@Id
@Column(name="ID")
@GeneratedValue
private long id;
@Column(name="FIRST_NAME")
private String firstName;
@Column(name="LAST_NAME")
private String lastName;
@OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL})
@JoinColumn(name="INTERPRETER_IMAGE")
private InterpreterImage interpreterImage;
@OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL})
@JoinColumn(name="INTERPRETER_DATA")
private InterpreterData interpreterData;
@Entity
@Table(name="INTERPRETER_DATA")
public class InterpreterData implements Serializable
{
private static final long serialVersionUID = 1;
@Id
@Column(name="ID")
private int id;
@Column(name="CERTIFICATE")
private String certificate;
@Entity
@Table(name="INTERPRETER_IMAGE")
public class InterpreterImage implements Serializable
{
private static final long serialVersionUID = 1;
@Id
@Column(name="ID")
private int id;
@Column(name="GALLERY_FILENAME")
private String galleryFilename;
Select Statement
Code:
+----+------------+-----------+-------------------+------------------+
| ID | FIRST_NAME | LAST_NAME | INTERPRETER_IMAGE | INTERPRETER_DATA |
+----+------------+-----------+-------------------+------------------+
| 1 | Sascha | Gerdes | 0 | 0 |
+----+------------+-----------+-------------------+------------------+
1 row in set (0.00 sec)
mysql> SELECT ID FROM INTERPRETER_IMAGE;
+----+
| ID |
+----+
| 1 |
+----+
1 row in set (0.00 sec)
mysql> SELECT ID FROM INTERPRETER_DATA;
+----+
| ID |
+----+
| 1 |
+----+
1 row in set (0.00 sec)
I hope you find my mistake.
Manu