I have two classes :
@Entity
@Table(name="profil")
public class Profil {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id")
private long id;
@OneToOne(mappedBy="profil")
private Avatar avatar;
+ getters and setters
}
and
@Entity
@Table(name="avatar")
public class Avatar {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id")
private Long id;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name="profil_id")
private Profil profil;
+getters and setters
}
But when i start my server i have the following error : Caused by: org.hibernate.AnnotationException: Unknown mappedBy in: com.startup.app.models.entities.Profil.avatar, referenced property unknown: com.startup.app.models.entities.Avatar.profil at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:153) at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1639) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1393) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1784) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1868) at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:247) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:373) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:358) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479) ... 126 more