-->
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.  [ 2 posts ] 
Author Message
 Post subject: @OneToOne resutling in org.hibernate.AnnotationException: Un
PostPosted: Tue Apr 19, 2011 2:12 am 
Newbie

Joined: Tue Apr 19, 2011 2:01 am
Posts: 1
Hi,

I have trying a simple onetoone parent child implemetation in hibernate. The relationship is help in the child class with a foreign key to the parent.

My 2 tables as as below :

Deal (t_deal)
-Id
-value date
-creator
-comment

DealDetails(t_deal_details)
-Id
-deal_id //fk to t_deal table
-additional_info

==============================
@Table(name="t_deal")
public class DealBean {
:
:
@Id
@GeneratedValue
public long getId() {
return id;
}

:
@OneToOne(mappedBy="dealBean")
public DealDetailsBean getDealDetailsBean() {
return dealDetailsBean;
}
}
-----------------------------------------------------
@Table(name="t_deal_details")
public class DealDetailsBean {
:
:
@Id
@GeneratedValue
public long getId() {
return id;
}

@GeneratedValue(generator="foreign")
@GenericGenerator(name="foreign", strategy = "foreign", parameters={
@Parameter(name="property", value="t_deal")
})
@Column(name="deal_id")
public long getDealId() {
return dealId;
}

:
:

@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
@JoinColumn(name="deal_id", unique=true)
public DealBean getDealBean() {
return dealBean;
}
========================================

I am not sure of what i am missing, i have seen numerous examples in the net dont know why mine doesnt seem to work.
I am getting the following exception:

org.hibernate.AnnotationException: Unknown mappedBy in: com.xxx.yyy.zzz.reportetl.model.DealBean.dealDetailsBean, referenced property unknown: com.xxx.yyy.zzz.reportetl.model.DealDetailsBean.dealBean
at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:129)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1127)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:329)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1283)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at com.xxx.yyy.zzz.reportetl.dao.HibernateSessionManager.getSessionFactory(HibernateSessionManager.java:48)
at com.jpmorgan.eragbat.eblotter.reportetl.DBPopulator.saveDeal(DBPopulator.java:110)
at com.jpmorgan.eragbat.eblotter.reportetl.DBPopulator.populateDatabase(DBPopulator.java:98)
at com.jpmorgan.eragbat.eblotter.tasks.AquaReportMigrationTask.execute(AquaReportMigrationTask.java:18)
at com.jpmorgan.eragbat.util.task.AbstractTask.run(AbstractTask.java:156)
at java.lang.Thread.run(Thread.java:619)


Thanks in advance


Top
 Profile  
 
 Post subject: Re: @OneToOne resutling in org.hibernate.AnnotationException: Un
PostPosted: Tue Apr 19, 2011 1:20 pm 
Newbie

Joined: Tue Sep 14, 2010 4:29 pm
Posts: 16
Quote:
Code:
@GeneratedValue(generator="foreign")
@GenericGenerator(name="foreign", strategy = "foreign", parameters={
@Parameter(name="property", value="t_deal")})
@Column(name="deal_id")
public long getDealId() {
    return dealId;
}

:
:

@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
@JoinColumn(name="deal_id", unique=true)
public DealBean getDealBean() {
  return dealBean;
}


I do not really understand, what you are trying to accomplish with these two mappings in DealDetailsBean. At the first sight, I would say they are contradictory as they both use the same name for column (or was that on purpose?).

Cheers ngomo

_________________
http://www.winfonet.eu


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

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.