[jboss-user] [EJB 3.0] - Re: onetomany relationship question
Wolfgang Knauf
do-not-reply at jboss.com
Tue Jul 7 05:18:58 EDT 2009
Hi,
Q1: for each child, you have to do this:
ParentBean parent = ...;
| ChildBean child1 = ...;
| ==> parent.getChilds().add (child1);
| child1.setParent(parent);
|
Otherwise, the relation will not be saved, but there will be no error message.
Q2: I don't know what is happening if you call "setChilds" before loading them, but I would expect strange side effects at least when the collection is under EntityManager control (inside a session bean method/transaction). So better manipulate the collection returned by "getChilds" and add/remove items. I will give this a try in the next few days and update my Wiki if I find a "No go".
Q3: Did you activate SQL query logging in your persistence.xml?
<?xml version="1.0" encoding="UTF-8"?>
| <persistence xmlns="http://java.sun.com/xml/ns/persistence"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
| version="1.0">
| <persistence-unit name="..">
| ...
| <properties>
| ...
| ===> <property name="hibernate.show_sql" value="true"></property>
| </properties>
| </persistence-unit>
| </persistence>
|
But I am not sure how the childs are loaded. I will take a look at the JBoss console when I near a computer with JBoss ;-)
Best regards
Wolfgang
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4242128#4242128
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4242128
More information about the jboss-user
mailing list