• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Persisting one domain object should persist other domain objects as well automaticly

 
taltun taltun
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Currently when I have an object User with e.g. Message

public class User {
private Long id;
private Message message = new Message("My Message");
...
}

public class UserService {

public saveUser(User user) {

// Currently I have this solution. I don't like this solution.
Message message = messageDao.save(user.getMessage);
user.setMessage(message);
userDao.save(user)

// I need this solution.
// The depended Message object is persisteted too automaticly without explicitly
// persist the message object before persisting the user obect separatly like above example.
userDao.save(user);

}
}

Is this possible ?

-taltun
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic