1 Reply Latest reply on Dec 17, 2011 4:51 AM by Thomas T

    how to create table which contains object-column?

    Joseph Hwang Novice

      I am develoiping simple entity-mapping project on jboss 7 and indigo.

      This is my source code :

       

      ======Members.java =======

      @Entity

      @Table(name = "family")

      public class Members implements Serializable {

          @Id

          @Column(name = "EMP_ID")

          private String id ;

       

          @Column(name = "EMP_Passwd")

          private String passwd ;

         

          @Column(name = "EMP_Name")

          private String name ;

       

          @Column(name="EMP_Record")

          @OneToMany(fetch=FetchType.EAGER, mappedBy="member", cascade=CascadeType.ALL)

          private List<Records> record = new ArrayList();

      ..........

       

      ======Records.java=========

      @Entity

      @Table(name = "info")

      public class Records implements Serializable {

          @Id

          @GeneratedValue(strategy=GenerationType.IDENTITY)

          @Column(name = "EMP_ID")

          private int i;

         

          @ManyToOne(fetch=FetchType.EAGER, cascade=CascadeType.ALL)

          @JoinColumn(name="EMP_Record")

          private Members member;   // this is the problem....

       

          @Column(name = "EMP_Bank_Account")

          private String account;

       

          @Column(name = "EMP_Hobby")

          private String hobby;

       

          @Column(name = "EMP_Phone")

          private int phone;

       

      I try to create 2 tables(family and info). Creation of family table is succeeded but i have some problem in creation of table info.

      I don't know how to create Members column in info table. It is java obejct class.

       

      create table info

      (

         ...

         Membser ????? //pls, advise me

         EMP_Bank_Account varchar(20) not null,

         EMP_Hobby varchar(20) not null,

         phone int

      ..........

       

      Pls inform me how to create table with java-object-column!

      Best Regards,