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: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
--
View this message in context:
http://www.nabble.com/manyToOne-need-assistance-in-changing-the-reference-type-in-database-%282%29-tp25185558s2369p25222574.html
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]