-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Trying to implement a LEFT OUTER JOIN
PostPosted: Thu Nov 17, 2005 11:31 am 
Newbie

Joined: Thu Nov 17, 2005 11:20 am
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

I've read every topic, studied every reference...i don't seem to be doing anything wrong, the example i've gone for is so simple!!! but it's still not working!!! i need this to work so that i can make something a bit more complicated to work also:

Hibernate version:3.0

Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.cme.chatter.bean.Person" table="person">
<id column="id" name="id" type="java.lang.Long">
<generator class="native"/>
</id>
<property column="name" length="45" name="name" not-null="true" type="java.lang.String"/>
<set name="emails" inverse="true">
<key column="person_id"/>
<one-to-many class="com.cme.chatter.bean.PersonEmails"/>
</set>
</class>
<class name="com.cme.chatter.bean.PersonEmails" table="person_emails">
<id column="id" name="id" type="java.lang.Long">
<generator class="native"/>
</id>
<property column="email" length="45" name="email" not-null="true" type="java.lang.String"/>
<many-to-one column="person_id" name="personId" class="com.cme.chatter.bean.Person" not-null="true" />
</class>
</hibernate-mapping>

Java Objects:

public class Person implements Serializable {

/** identifier field */
private Long id;

/** persistent field */
private String name;

private Set emails = new HashSet();

/** full constructor */
public Person(String value) {
this.name = value;
}

/** default constructor */
public Person() {
}

public Long getId() {
return this.id;
}

public void setId(Long id) {
this.id = id;
}

public String getName() {
return this.name;
}

public void setName(String value) {
this.name = value;
}

public String toString() {
return new ToStringBuilder(this)
.append("id", getId())
.toString();
}


public Set getEmails() {
return emails;
}

public void setEmails(Set emails) {
this.emails = emails;
}

}
*********************************
public class PersonEmails implements Serializable {

/** identifier field */
private Long id;

/** persistent field */
private Integer personId;

/** persistent field */
private String email;

/**
*default constructor
*/
public PersonEmails() {
}
/**
* @return Returns the email.
*/
public String getEmail() {
return email;
}
/**
* @param email The email to set.
*/
public void setEmail(String email) {
this.email = email;
}
/**
* @return Returns the id.
*/
public Long getId() {
return id;
}
/**
* @param id The id to set.
*/
public void setId(Long id) {
this.id = id;
}
/**
* @return Returns the personId.
*/
public Integer getPersonId() {
return personId;
}
/**
* @param personId The personId to set.
*/
public void setPersonId(Integer personId) {
this.personId = personId;
}
}


Code between sessionFactory.openSession() and session.close():
Query q = hibSession.createQuery("FROM Person as person LEFT OUTER JOIN Person.emails as emails");
List list = q.list();

for (int i=0; i<list.size(); i++) {
Object[] item = (Object[])list.get(i);
Person p = (Person)item[0];
Set s = new HashSet();
s = p.getEmails();
String[] emails = (String[]) s.toArray();
ChatLog.debug("name: " + p.getName(), PhoneCallsAction.class);
ChatLog.debug("emails: ", PhoneCallsAction.class);
for (int j=0; j<emails.length; j++) {
ChatLog.debug(emails[j], PhoneCallsAction.class);
}
}

Full stack trace of any exception that occurs:

2005-11-17 17:23:21,205 [http-8080-Processor4] DEBUG - find: FROM Person as person LEFT OUTER JOIN Person.emails as emails
2005-11-17 17:23:21,205 [http-8080-Processor4] DEBUG - named parameters: {}
2005-11-17 17:23:21,205 [http-8080-Processor4] DEBUG - parse() - HQL: FROM com.cme.chatter.bean.Person as person LEFT OUTER JOIN Person.emails as emails
2005-11-17 17:23:21,205 [http-8080-Processor4] DEBUG - --- HQL AST ---
\-[QUERY] 'query'
\-[SELECT_FROM] 'SELECT_FROM'
\-[FROM] 'FROM'
+-[RANGE] 'RANGE'
| +-[DOT] '.'
| | +-[DOT] '.'
| | | +-[DOT] '.'
| | | | +-[DOT] '.'
| | | | | +-[IDENT] 'com'
| | | | | \-[IDENT] 'cme'
| | | | \-[IDENT] 'chatter'
| | | \-[IDENT] 'bean'
| | \-[IDENT] 'Person'
| \-[ALIAS] 'person'
\-[JOIN] 'JOIN'
+-[LEFT] 'LEFT'
+-[OUTER] 'OUTER'
+-[DOT] '.'
| +-[IDENT] 'Person'
| \-[IDENT] 'emails'
\-[ALIAS] 'emails'

2005-11-17 17:23:21,205 [http-8080-Processor4] DEBUG - throwQueryException() : no errors
2005-11-17 17:23:21,205 [http-8080-Processor4] DEBUG - query() << begin, level = 1
2005-11-17 17:23:21,205 [http-8080-Processor4] DEBUG - FromClause{level=1} : com.cme.chatter.bean.Person (person) -> person0_
2005-11-17 17:23:21,236 [http-8080-Processor4] ERROR - *** ERROR: Invalid path: 'Person.emails'
2005-11-17 17:23:21,246 [http-8080-Processor4] DEBUG - Invalid path: 'Person.emails'
Invalid path: 'Person.emails'
at org.hibernate.hql.ast.LiteralProcessor.lookupConstant(LiteralProcessor.java:85)
at org.hibernate.hql.ast.DotNode.resolve(DotNode.java:172)
at org.hibernate.hql.ast.FromReferenceNode.resolve(FromReferenceNode.java:87)
at org.hibernate.hql.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:262)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3022)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:2841)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2719)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:513)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:371)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at com.cme.chatter.action.TestAction.execute(TestAction.java:52)
at com.cme.commons.action.HibernateAction.execute(HibernateAction.java:41)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Unknown Source)
2005-11-17 17:23:21,246 [http-8080-Processor4] DEBUG - query() : finishing up , level = 1
2005-11-17 17:23:21,246 [http-8080-Processor4] DEBUG - processQuery() : ( SELECT ( FromClause{level=1} person person0_ ) )
2005-11-17 17:23:21,246 [http-8080-Processor4] DEBUG - Derived SELECT clause created.
2005-11-17 17:23:21,246 [http-8080-Processor4] DEBUG - Using FROM fragment [person person0_]
2005-11-17 17:23:21,246 [http-8080-Processor4] DEBUG - query() >> end, level = 1
2005-11-17 17:23:21,246 [http-8080-Processor4] DEBUG - --- SQL AST ---
\-[SELECT] QueryNode: 'SELECT' querySpaces (person)
+-[SELECT_CLAUSE] SelectClause: '{derived select clause}'
| +-[SELECT_EXPR] SelectExpressionImpl: 'person0_.id as id' {FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=person,role=null,tableName=person,tableAlias=person0_,colums={,className=com.cme.chatter.bean.Person}}}
| \-[SQL_TOKEN] SqlFragment: 'person0_.name as name28_'
\-[FROM] FromClause: 'FROM' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[person], fromElementByTableAlias=[person0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
\-[FROM_FRAGMENT] FromElement: 'person person0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=person,role=null,tableName=person,tableAlias=person0_,colums={,className=com.cme.chatter.bean.Person}}

2005-11-17 17:23:21,246 [http-8080-Processor4] ERROR - com.cme.chatter.action.TestAction - EXIT FAIL execute() org.hibernate.hql.ast.QuerySyntaxError: Invalid path: 'Person.emails' [FROM com.cme.chatter.bean.Person as person LEFT OUTER JOIN Person.emails as emails]
2005-11-17 17:23:21,256 [http-8080-Processor4] DEBUG - closing session

Name and version of the database you are using: MySQL 4.1


Top
 Profile  
 
 Post subject: master detail
PostPosted: Thu Nov 17, 2005 2:19 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
See order and line item mappings for an inspiration
http://www.hibernate.org/hib_docs/v3/re ... derproduct

And in your code:
- firstly you do not need any joins, just "from Person" will give you all the necessary data including emails; -it is Hibernate magic :)

-secondly String[] emails = (String[]) s.toArray(); will blow up because set is going to contain PersonEmails instances

- 3rd PersonEmails is a misleading name, I suggest renaming to PersonEmail

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 18, 2005 3:40 am 
Newbie

Joined: Thu Nov 17, 2005 11:20 am
Posts: 2
HI...thanks for your help...I just put the query as "FROM Person", but then it gave me the following exception:

2005-11-18 09:13:54,168 [http-8080-Processor22] DEBUG - parse() - HQL: FROM com.cme.chatter.bean.Person
2005-11-18 09:13:54,178 [http-8080-Processor22] DEBUG - --- HQL AST ---
\-[QUERY] 'query'
\-[SELECT_FROM] 'SELECT_FROM'
\-[FROM] 'FROM'
\-[RANGE] 'RANGE'
\-[DOT] '.'
+-[DOT] '.'
| +-[DOT] '.'
| | +-[DOT] '.'
| | | +-[IDENT] 'com'
| | | \-[IDENT] 'cme'
| | \-[IDENT] 'chatter'
| \-[IDENT] 'bean'
\-[IDENT] 'Person'

2005-11-18 09:13:54,178 [http-8080-Processor22] DEBUG - throwQueryException() : no errors
2005-11-18 09:13:54,188 [http-8080-Processor22] DEBUG - query() << begin, level = 1
2005-11-18 09:13:54,188 [http-8080-Processor22] DEBUG - FromClause{level=1} : com.cme.chatter.bean.Person (no alias) -> person0_
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - query() : finishing up , level = 1
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - processQuery() : ( SELECT ( FromClause{level=1} person person0_ ) )
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - Derived SELECT clause created.
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - Using FROM fragment [person person0_]
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - query() >> end, level = 1
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - --- SQL AST ---
\-[SELECT] QueryNode: 'SELECT' querySpaces (person)
+-[SELECT_CLAUSE] SelectClause: '{derived select clause}'
| +-[SELECT_EXPR] SelectExpressionImpl: 'person0_.id as id' {FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=person,tableAlias=person0_,colums={,className=com.cme.chatter.bean.Person}}}
| \-[SQL_TOKEN] SqlFragment: 'person0_.name as name28_'
\-[FROM] FromClause: 'FROM' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[], fromElementByTableAlias=[person0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
\-[FROM_FRAGMENT] FromElement: 'person person0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=person,tableAlias=person0_,colums={,className=com.cme.chatter.bean.Person}}

2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - throwQueryException() : no errors
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - HQL: FROM com.cme.chatter.bean.Person
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - SQL: select person0_.id as id, person0_.name as name28_ from person person0_
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - throwQueryException() : no errors
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - opening JDBC connection
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - select person0_.id as id, person0_.name as name28_ from person person0_
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - preparing statement
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - processing result set
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - result set row: 0
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - result row: EntityKey[com.cme.chatter.bean.Person#1]
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - Initializing object from ResultSet: [com.cme.chatter.bean.Person#1]
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - Hydrating entity: [com.cme.chatter.bean.Person#1]
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - result set row: 1
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - result row: EntityKey[com.cme.chatter.bean.Person#2]
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - Initializing object from ResultSet: [com.cme.chatter.bean.Person#2]
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - Hydrating entity: [com.cme.chatter.bean.Person#2]
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - result set row: 2
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - result row: EntityKey[com.cme.chatter.bean.Person#3]
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - Initializing object from ResultSet: [com.cme.chatter.bean.Person#3]
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - Hydrating entity: [com.cme.chatter.bean.Person#3]
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - result set row: 3
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - result row: EntityKey[com.cme.chatter.bean.Person#4]
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - Initializing object from ResultSet: [com.cme.chatter.bean.Person#4]
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - Hydrating entity: [com.cme.chatter.bean.Person#4]
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - done processing result set (4 rows)
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - closing statement
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - total objects hydrated: 4
2005-11-18 09:13:54,198 [http-8080-Processor22] DEBUG - resolving associations for [com.cme.chatter.bean.Person#1]
2005-11-18 09:13:54,208 [http-8080-Processor22] DEBUG - creating collection wrapper:[com.cme.chatter.bean.Person.emails#1]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - done materializing entity [com.cme.chatter.bean.Person#1]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - resolving associations for [com.cme.chatter.bean.Person#2]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - creating collection wrapper:[com.cme.chatter.bean.Person.emails#2]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - done materializing entity [com.cme.chatter.bean.Person#2]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - resolving associations for [com.cme.chatter.bean.Person#3]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - creating collection wrapper:[com.cme.chatter.bean.Person.emails#3]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - done materializing entity [com.cme.chatter.bean.Person#3]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - resolving associations for [com.cme.chatter.bean.Person#4]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - creating collection wrapper:[com.cme.chatter.bean.Person.emails#4]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - done materializing entity [com.cme.chatter.bean.Person#4]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - initializing non-lazy collections
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - after autocommit
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - after transaction completion
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - com.cme.chatter.action.TestAction - ***********printing items
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - initializing collection [com.cme.chatter.bean.Person.emails#1]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - checking second-level cache
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - collection not cached
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - loading collection: [com.cme.chatter.bean.Person.emails#1]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - select emails0_.person_id as person3_1_, emails0_.id as id1_, emails0_.id as id0_, emails0_.email as email29_0_, emails0_.person_id as person3_29_0_ from person_emails emails0_ where emails0_.person_id=?
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - preparing statement
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - result set contains (possibly empty) collection: [com.cme.chatter.bean.Person.emails#1]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - uninitialized collection: initializing
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - processing result set
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - result set row: 0
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - result row: EntityKey[com.cme.chatter.bean.PersonEmails#1]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - Initializing object from ResultSet: [com.cme.chatter.bean.PersonEmails#1]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - Hydrating entity: [com.cme.chatter.bean.PersonEmails#1]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - found row of collection: [com.cme.chatter.bean.Person.emails#1]
2005-11-18 09:13:54,218 [http-8080-Processor22] DEBUG - reading row
2005-11-18 09:13:54,228 [http-8080-Processor22] DEBUG - loading entity: [com.cme.chatter.bean.PersonEmails#1]
2005-11-18 09:13:54,228 [http-8080-Processor22] DEBUG - attempting to resolve: [com.cme.chatter.bean.PersonEmails#1]
2005-11-18 09:13:54,228 [http-8080-Processor22] DEBUG - resolved object in session cache: [com.cme.chatter.bean.PersonEmails#1]
2005-11-18 09:13:54,228 [http-8080-Processor22] DEBUG - done processing result set (1 rows)
2005-11-18 09:13:54,228 [http-8080-Processor22] DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
2005-11-18 09:13:54,228 [http-8080-Processor22] DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-11-18 09:13:54,228 [http-8080-Processor22] DEBUG - closing statement
2005-11-18 09:13:54,228 [http-8080-Processor22] DEBUG - total objects hydrated: 1
2005-11-18 09:13:54,228 [http-8080-Processor22] DEBUG - resolving associations for [com.cme.chatter.bean.PersonEmails#1]
2005-11-18 09:13:54,228 [http-8080-Processor22] DEBUG - loading entity: [com.cme.chatter.bean.Person#1]
2005-11-18 09:13:54,228 [http-8080-Processor22] DEBUG - entity found in session cache
2005-11-18 09:13:54,238 [http-8080-Processor22] ERROR - com.cme.chatter.action.TestAction - EXIT FAIL execute() org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.cme.chatter.bean.PersonEmails.setPersonId



I hope my problem is not serious. can u help?


Top
 Profile  
 
 Post subject: mapping
PostPosted: Fri Nov 18, 2005 12:04 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
At a quick glance in your PersonEmail class you should have:
<many-to-one column="person_id" name="person" class="com.cme.chatter.bean.Person" not-null="true" />

and corresponding getter and setter

public Person getPerson(){return preson;}
public void setPerson( Person p ){ person = p;}

not your getter and setter for personId.

To get more information about binding and related errors you need to start your JVM with parameter -Dhibernate.cglib.use_reflection_optimizer=false

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 18, 2005 12:11 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
change
FROM Person as person LEFT OUTER JOIN Person.emails as emails
to
FROM Person as person LEFT OUTER JOIN person.emails as emails


maybe you did a typo in the forum and your code is ok...

also have in mind that in person.emails as emails , the emails alias refers to an element of the emails collection, so, to be easier to understand, your query should look like

FROM Person as person LEFT OUTER JOIN person.emails as email

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.