-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: using @OneToOne relation, save(Parent) throws exception....
PostPosted: Thu Mar 12, 2015 10:20 am 
Newbie

Joined: Thu Mar 12, 2015 9:58 am
Posts: 1

I am using @OneToOne Relation ship(Bi-directional)

Parent
@Entity
@Table(name="student")
public class Student {
@Id
@GeneratedValue

private int sno;

@Column(name="name")
private String name;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name="sno",unique=true,nullable=false)
private Address address;
//setters and getters

Child:
@Id
@GeneratedValue(generator="gen")
@GenericGenerator(name = "gen", strategy = "foreign",parameters= @Parameter(name = "property", value = "student"))

private int sno;

@Column(name="state")
private String state;
@OneToOne(cascade=CascadeType.ALL)
@PrimaryKeyJoinColumn
private Student student;
//setters and getters
.when i am calling save(Parent) it throws the following exception::
exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.id.IdentifierGenerationException: attempted to assign id from null one-to-one property [info.inetsolv.models.Address.student]
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:927)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:822)
javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
root cause

org.hibernate.id.IdentifierGenerationException: attempted to assign id from null one-to-one property [info.inetsolv.models.Address.student]
org.hibernate.id.ForeignGenerator.generate(ForeignGenerator.java:102)


When i am calling save(Child) it is working fine

please help me.i want to save records by claaing save(parent)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.