This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Members are not poppulated? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Members are not poppulated?" Watch "Members are not poppulated?" New topic
Author

Members are not poppulated?

Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Hi guys! I'm trying to select record from the database and map it into my class. I'm using JPA and Toplink. First of all, here is my query.




My entity class




As you can see, I'm thinking that userId and all other fields would already be poppulated. But when I supply correct data for the username and password and the Object is retrieved, its members especially the userId is not filled. Why is that? Thanks!


SCJP 1.5
http://devpinoy.org/blogs/lamia/ - http://everypesocounts.com/
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Probably because it assumes that youa re going to fill that in, because your mapping is

@Id
@Column(name = "user_id", nullable = false)
private Integer userId;

Where is the @GeneratedValue to tell it to generate the value?

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
Consider Paul's rocket mass heater.
 
subject: Members are not poppulated?
 
Similar Threads
EntityManager is null!! what can be the problem?
Can a class be mapped to a table and be Embeddable at the same time?
Need help with Mapping(Annotation) and Composition
could not load an entity - JPA and Hibernate
Internal Exception: java.sql.SQLException: Invalid object name