File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes JPA and One-to-One blues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPA and One-to-One blues" Watch "JPA and One-to-One blues" New topic
Author

JPA and One-to-One blues

André-John Mas
Ranch Hand

Joined: Oct 18, 2008
Posts: 37
I have two tables: user and phone_number. The phone_number id corresponds to the id of the user. A user can have one phone number, and it is optional. I just don't get what I should be doing.

I tried:



What I get is:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'openEntityInView' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: org.hibernate.MappingException: Could not determine type for: com.realbusinesses.entity.PhoneNumber, at table: user, for columns: [org.hibernate.mapping.Column(phoneNumber)]

Any help would be appreciated. I am pulling my hair out here. It is probably 'obvious', but I am just not seeing it.
André-John Mas
Ranch Hand

Joined: Oct 18, 2008
Posts: 37
Turns out the issues was with where I was putting my annotations. Moving them to the public getters and setters in both cases cleared up the issue.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPA and One-to-One blues