Thanks for the reply paulie, i have follow up question.

When i look at may table Person. The name of the Primary key is "id".. Which I am confused with your answer. Why it is supposed to be @JoinColumn(name="PersonId") not @JoinColumn(name="id") ... There is no existing column name that was named "PersonId" in Person table. How is it possible to connect the two tables. Is this mean that if i have Table named "State" and has a relation of ManyToOne in "Country" table.. I will use "CountryId" also? is this the way of annotation to
reference there parent table?

paulie wrote:
You need to define which field in Person will be the foreign key:

   @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
   @JoinColumn(name="PersonId")



shendel_18 wrote:
Hello im using appfuse 2, i need help on how to change the value type in
database.

Example.

ManytoOne (Person many Address)
each Address associated with a Person via a many-to-one relationship (in
other words, each Address  is associated with exactly one Person)

Person person = new Person ();
Address address = new Address ();

address.setParentPerson(person);

The parentPerson object of the Address is successfully save but the
problem
is that, the save object in database has the type value of tinyblob (which
it saves the whole object) i expect it to be only ID that will be
referencing to the person's ID in the table Person.. How can i save just
the
id of the person's id in the parentPerson column in the Address table.


Here is my code in Address:

@Entity @Table(name="address")
public class Address extends BaseObject {
   private Long id;
   private String gsID;
   private String description;

   public Address() {}


   @Column(name="gsID", length=50)
   public String getGsID() {
               return gsID;
       }

       public void setGsID(String gsID) {
               this.gsID = gsID;
       }


   @Column(name="description", length=50)
   public String getDescription() {
       return description;
   }

   public void setDescription(String description) {
       this.description = description;
   }



   @Id @GeneratedValue(strategy = GenerationType.AUTO)
   public Long getId() {
       return id;
   }

   public void setId(Long id) {
       this.id <http://this.id> = id;
   }

   @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
   private Person parentPerson;

       public Person getParentPerson() {
               return parentPerson;
       }


       public void setParentPerson(Person parentPerson) {
               this.parentPerson = parentPerson;
       }


Can anyone assist me with my problem..


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net






---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net

Reply via email to