EJB entitybean question

D

Donkey Hot

Lets have an entitybean, say UserBean

class UserBean extends EntityBean
{
Long id ;
String name ;
Integer height ;
...
// and the getters and setters
}


// and the Local and Remote interfaces... and a POJO with similar
// properties..


How does the EJB (2.x) container generate SQL when updating entitybeans
properties?

I have seen code like this

void updateUser(UserPOJO user)
{
UserLocal userLocal = UserLocalHome.findByPrimaryKey(
new UserKey(user.getId()) ; // or something

if (!user.getName().equals(userLocal.getName())
userLocal.setName(user.getName()) ;

if (!user.getHeight().equals(userLocal.getHeight())
userLocal.setHeight(user.getHeight()) ;
}

Do the ejb setters mark properties as dirty, and generate SQL according to
that, or would the end result be same, if the all properties would be
always updated without checking if there is any difference?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,261
Messages
2,571,040
Members
48,769
Latest member
Clifft

Latest Threads

Top