This week's giveaway is in the Java/Jakarta EE forum.
We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line!
See welcome thread
Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

@ManyToOne RelationShip  RSS feed

Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Every buddy
I am getting problem in ManyToOne Relationship.I am not getting that how to call entity.persist()from client.Because there will be two object of owing side class.
My proble is like this....

public class Person implements Serializable {
@Column(name = "ID", nullable = false)
private Long id;

private Address address=new Address();

public class Address implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "ID", nullable = false)
private BigDecimal id;

Client Or servlet{

String fname=request.getParameter("fname");
String lname=request.getParameter("lname");
String city=request.getParameter("city");
String country=request.getParameter("country");

Address d=new Address();

Pankaj p1=new Pankaj();

Pankaj p2=new Pankaj();

remote.CreateCruise(p1); remote.CreateCruise(p2);

My problem is i want in peson table two persons should be created whilw in Address table one value should go.
just please tell me wats worng in servlet class.
@OneToMany realtionship is working properly but this isn't.

I just want to create two pesons in person table & one address in Address table. please help me.........
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Panki,

I'm new to EJB so may not be able to help you.

If you have a ManyToOne relationship, that means that there are many entities owning the relationship to a single entity. In that case, why bother with a join table?
AFAIK, the join table is only required for the OneToMany relationship (where one entity owns a relationship to many others - but only has a single space in it's row).

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!