Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Re: Mapping Compound PK with FK Reference?
Re: Mapping Compound PK with FK Reference? [message #758004] Thu, 17 November 2011 21:30
Shelli Orton is currently offline Shelli OrtonFriend
Messages: 76
Registered: September 2009
Member
Through much trial and error, here is the correct setup:

@Entity
public class Child
{
private ChildPK childId;
private String string1;

public Child()
{
// empty constructor
}

@EmbeddedId
public ChildPK getChildId()
{
return childId;
}

public void setChildId(ChildPK childId)
{
this.childId= childId;
}


@Column(name = "STRING1")
public String getString1()
{
return string1;
}

public void setString1(String string1)
{
this.string1 = string1;
}

// bi-directional many-to-one association to Parent
@ManyToOne
@JoinColumn(name = "PARENT_NAME", updatable=false, insertable=false)
public Parent getParent()
{
return this.parent;
}

public void setParent(Parent parent)
{
this.parent = parent;
}

}

@Embeddable
public class ChildPK implements Serializable
{
private static final long serialVersionUID = 1L;
private String name;
private String parentName;

public ChildPK()
{
//empty
}


@Column(name = "NAME")
public String getName()
{
return name;
}

public void setName(String name)
{
this.name= name;
}

@Column(name = "PARENT_NAME")
public String getParentName()
{
return parentName;
}

public void setParentName(String parentName)
{
this.parentName= parentName;
}
}
Previous Topic:Mapping Compound PK with FK Reference?
Next Topic:Calling preparedStatement/Function the JPA way
Goto Forum:
  


Current Time: Sat Nov 29 09:04:42 GMT 2014

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

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