Skip to main content


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: 101
Registered: September 2009
Senior 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: Thu Apr 18 18:54:13 GMT 2024

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

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

Back to the top