I preface this with the fact that I'm using a snapshot build
resin-3.1.s080205 because of this bug
(http://bugs.caucho.com/view.php?id=2282).

Even though I have my OneToMany relationship tagged as EAGER, it appears to
behave as if it's in LAZY mode.  Here are snippets from my classes.

public class DatabaseQuestionImpl implements Serializable, Question {

...
    @OneToMany(mappedBy="parentQuestion", fetch=FetchType.EAGER, cascade =
CascadeType.ALL)
    private List<DatabaseOptionImpl> optionsFromDatabase;

...
}

public class DatabaseOptionImpl implements Serializable, Option {

...
    @ManyToOne()
    @JoinColumn(name="parent_question_id")
    private DatabaseQuestionImpl parentQuestion;
...
}

Here are logs entries from a case where I do a find(Class, Id) on the
question class, update some fields on it, and then iterate through the
options.  You can see that there is a select statement for the question,
then an update statement and then another select statement for the options. 
My understanding of EAGER loading is that the find operation should have
retrieved the entire graph.  Is this a bug, or a misunderstanding on my
part?

[18:53:49.515] FINE
com.amirsys.pathwork.entity.dynamicquestion.DatabaseQuestionImpl amber
expire com.amirsys.pathwork.entity.dynamicquestion.DatabaseQuestionImpl[1]
[18:53:49.515] FINEST com.caucho.amber.manager.AmberConnection amber
com.amirsys.pathwork.entity.dynamicquestion.DatabaseQuestionImpl[1]
addInternalEntity
[18:53:49.515] FINE com.caucho.sql.spy.SpyConnection.XA
jdbc/postgres.0:setAutoCommit(false)
[18:53:49.515] FINE com.caucho.sql.spy.SpyConnection
jdbc/postgres.0.18:prepareStatement(select o.multipleAnswersPermitted,
o.questionText, o.rootQuestion from question o where
o.id=?,type=1003,concurrency=1007)
[18:53:49.515] FINE com.caucho.sql.spy.SpyPreparedStatement
jdbc/postgres.0.18:setLong(1,1)
[18:53:49.515] FINE com.caucho.sql.spy.SpyPreparedStatement
jdbc/postgres.0.18:executeQuery(select o.multipleAnswersPermitted,
o.questionText, o.rootQuestion from question o where o.id=?)
[18:53:49.515] FINER
com.amirsys.pathwork.entity.dynamicquestion.DatabaseQuestionImpl amber
loaded-0 com.amirsys.pathwork.entity.dynamicquestion.DatabaseQuestionImpl
[18:53:49.515] FINER com.caucho.amber.entity.RowInvalidateCompletion
RowInvalidateCompletion table: question key: 1
[18:53:49.515] FINE com.caucho.sql.spy.SpyConnection
jdbc/postgres.0:isClosed() -> false
[18:53:49.515] FINE com.caucho.sql.spy.SpyConnection
jdbc/postgres.0.19:prepareStatement(update question set
multipleAnswersPermitted=?, questionText=?, rootQuestion=? where
id=?,type=1003,concurrency=1007)
[18:53:49.515] FINE com.caucho.sql.spy.SpyPreparedStatement
jdbc/postgres.0.19:setBoolean(1,true)
[18:53:49.515] FINE com.caucho.sql.spy.SpyPreparedStatement
jdbc/postgres.0.19:setString(2,What clinical )
[18:53:49.515] FINE com.caucho.sql.spy.SpyPreparedStatement
jdbc/postgres.0.19:setBoolean(3,true)
[18:53:49.515] FINE com.caucho.sql.spy.SpyPreparedStatement
jdbc/postgres.0.19:setLong(4,1)
[18:53:49.687] FINE com.caucho.sql.spy.SpyPreparedStatement
jdbc/postgres.0.19:executeUpdate(update question set
multipleAnswersPermitted=?, questionText=?, rootQuestion=? where id=?) -> 1
[18:53:49.687] FINE
com.amirsys.pathwork.entity.dynamicquestion.DatabaseQuestionImpl amber
update com.amirsys.pathwork.entity.dynamicquestion.DatabaseQuestionImpl -
PK: 1
[18:53:49.687] FINE com.caucho.sql.spy.SpyConnection
jdbc/postgres.0:isClosed() -> false
[18:53:49.687] FINE com.caucho.sql.spy.SpyConnection
jdbc/postgres.0.20:prepareStatement(select c.id, c.followUpQuestionId,
c.freeForm, c.optionType, c.parent_question_id, c.valueAsString from
question o, option c where (c.parent_question_id = o.id) and (o.id =
?),type=1003,concurrency=1007)
[18:53:49.687] FINE com.caucho.sql.spy.SpyPreparedStatement
jdbc/postgres.0.20:clearParameters()
[18:53:49.687] FINE com.caucho.sql.spy.SpyPreparedStatement
jdbc/postgres.0.20:setLong(1,1)
[18:53:49.687] FINE com.caucho.sql.spy.SpyPreparedStatement
jdbc/postgres.0.20:executeQuery(select c.id, c.followUpQuestionId,
c.freeForm, c.optionType, c.parent_question_id, c.valueAsString from
question o, option c where (c.parent_question_id = o.id) and (o.id = ?))

-- 
View this message in context: 
http://www.nabble.com/Amber-trouble-with-OneToMany-eager-loading-tp15368081p15368081.html
Sent from the Resin mailing list archive at Nabble.com.



_______________________________________________
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest

Reply via email to