Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Members are not poppulated?" Watch "Members are not poppulated?" New topic

Members are not poppulated?

Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 751
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 -
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

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

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

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


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Members are not poppulated?
It's not a secret anymore!