Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Java,Hibernate,Xdoclet question

  Asked By: Ronnie    Date: Mar 22    Category: Java    Views: 874
  

I'm working with Xdoclet and Hibernate.I have a one-to-many relationship for examle
Computer and hardware (computer 1 ------------ * hardware ).
In computer entity bean I have defined hadrwares atrribute with Set Type.
When I use setHardwares(Set hwList) method It works correctly but when I save the session (Hibernate session) There is no effect in DB.
Have you ever come acroos with this kind of problem.?
If so. please tell me where can be the problem.

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Blaze Fischer     Answered On: Mar 22

Check if you have specified cascade attribute. If it didn't work please send your code (tags are enough).

 
Answer #2    Answered By: Pam Harrison     Answered On: Mar 22

- Make sure you flush the session  or commit the transaction
- Make sure the cascade attribute of the association is set  to "save" or
"all", otherwise if you save  a Computer it won't save the dependent objects.
- If it's a bidirectional association, make sure you also set the other end
of the association (a setParentComputer in Hardware?).

 
Answer #3    Answered By: Shannon Hughes     Answered On: Mar 22

one comment here:

CMT demarcation must be used by Entity EJB components

cascade is used for deleting complex relationships not for setting them

because you have a 1-> * relationship you need to consider to use a Composite Entity and define your Business Objects as POJOs, it's very difficult and error prone to have all Business Objects as Entity Beans and also it's not a good practice to do so

I'd say

1. Review how you have defined/designed your complex Entity relationship
2. Review the specification relative to your EJB version for transaction demarcation

but still have in mind

CMT demarcation must be used by Entity EJB components

 
Didn't find what you were looking for? Find more on Java,Hibernate,Xdoclet question Or get search suggestion and latest updates.