-->
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.  [ 4 posts ] 
Author Message
 Post subject: Strange Problem with <properties/> Mapping
PostPosted: Mon Nov 07, 2005 8:06 pm 
Newbie

Joined: Mon Nov 07, 2005 6:51 pm
Posts: 2
Hi!

I try to map a few unique constraint over three columns with a <properties/> mapping, but in the most mapping constellations this produces strange errors with some operations. Hibernate says that one of the properties can't be resolved, but the property is definitely there. The debug messages show that it's there.

It's hard to describe when this problems occur. Joins are mostly a problem (like in this concrete example), but sometime simple queries, too.

If i remove the properties mapping the query works fine.

I use the properties-mapping only for getting a unique-constraint. the properties-group isn't a key for a foreign-key or something like this.

Any ideas?

Is this a bug or am I to stupid? The <properties/> mapping seems not to be used very often.

Best regards,
Stefan Kiendl



Hibernate version: 3.0.5

Mapping documents:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class dynamic-update="true" table="laborax_sequencing_analysissample" batch-size="100" lazy="true" name="AnalysisSample">
<id name="id">
<generator class="native"/>
</id>
<version unsaved-value="undefined" access="field" name="version"/>
<properties unique="true" name="wellUniqueConstraint">
<property name="col" not-null="true" access="field"/>
<many-to-one column="plate_id" foreign-key="FK_seq_analysissample_plate" access="field" cascade="save-update" name="plate" class="Plate"/>
<property name="row" not-null="true" access="field"/>
</properties>
<bag lazy="true" inverse="true" cascade="all" order-by="id" name="lastReadsPerPrimer" where="id in (select max(lsr_0.id) from ">
<key column="analysisSample_id"/>
<one-to-many class="Read"/>
</bag>
<many-to-one unique="true" column="primer_id" foreign-key="FK_seq_analysissample_primer" cascade="save-update" name="primer" class="PrimerSample"/>
<bag lazy="true" inverse="true" cascade="all-delete-orphan" order-by="id" name="reads">
<key column="analysisSample_id"/>
<one-to-many class="Read"/>
</bag>
<many-to-one column="sample_id" foreign-key="FK_seq_analysissample_sample" cascade="save-update" name="sample" class="Sample"/>
<property name="controlSample" not-null="true"/>
<property name="notAllocatable" not-null="true" access="field"/>
</class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():

This is the most important part:

List plateSamples = HibernateUtil.getSession().createQuery(
"select read from Read read left join read.well as well where well.id is null and read.locked = true and read.analysisSample.sample.order = :o and read.analysisSample.plate.product in (select elements(at.products) from AnalysisType as at where :workgroup in elements(at.workgroups)) order by read.id asc").setEntity("o", o).setEntity("workgroup", w).list();


Full stack trace of any exception that occurs:

See below.


Name and version of the database you are using: MySQL 4.1.10a using InnoDB Storage Engine, MySQL JDBC Driver 3.0.17

The generated SQL (show_sql=true):

No SQL is generated. Exception is thrown before the query.

Debug level Hibernate log excerpt:

Mapping class: de.kiendl_solutions.laborax.modules.sequencing.model.AnalysisSample -> laborax_sequencing_analysissample
Mapped property: id -> id
Mapped property: version -> version
Mapped property: col -> col
Mapped property: plate -> plate_id
Mapped property: row -> row
Mapped property: wellUniqueConstraint -> col, plate_id, row
Mapped property: lastReadsPerPrimer
Mapped property: primer -> primer_id
Mapped property: reads
Mapped property: sample -> sample_id
Mapped property: controlSample -> controlSample
Mapped property: notAllocatable -> notAllocatable

.....................................

find: select s.order from Sample s left join s.analysisSamples ass left join ass.reads as read where read.locked = true and s.dateRelease is not null and s.dateCompleted is null and ass.pla
te.product in (select elements(at.products) from AnalysisType as at where :workgroup in elements(at.workgroups)) group by s.order.id order by s.order.dateRelease asc
named parameters: {workgroup=de.kiendl_solutions.laborax.model.Workgroup#1}
parse() - HQL: select s.order from de.kiendl_solutions.laborax.modules.sequencing.model.Sample s left join s.analysisSamples ass left join ass.reads as read where read.locked = true and s.d
ateRelease is not null and s.dateCompleted is null and ass.plate.product in (select elements(at.products) from de.kiendl_solutions.laborax.modules.sequencing.model.AnalysisType as at where
:workgroup in elements(at.workgroups)) group by s.order.id order by s.order.dateRelease asc
*** WARNING: Keyword 'order' is being intepreted as an identifier due to: expecting IDENT, found 'order'
*** WARNING: Keyword 'order' is being intepreted as an identifier due to: expecting IDENT, found 'order'
*** WARNING: Keyword 'order' is being intepreted as an identifier due to: expecting IDENT, found 'order'
--- HQL AST ---
\-[QUERY] 'query'
+-[SELECT_FROM] 'SELECT_FROM'
| +-[FROM] 'from'
| | +-[RANGE] 'RANGE'
| | | +-[DOT] '.'
| | | | +-[DOT] '.'
| | | | | +-[DOT] '.'
| | | | | | +-[DOT] '.'
| | | | | | | +-[DOT] '.'
| | | | | | | | +-[DOT] '.'
| | | | | | | | | +-[IDENT] 'de'
| | | | | | | | | \-[IDENT] 'kiendl_solutions'
| | | | | | | | \-[IDENT] 'laborax'
| | | | | | | \-[IDENT] 'modules'
| | | | | | \-[IDENT] 'sequencing'
| | | | | \-[IDENT] 'model'
| | | | \-[IDENT] 'Sample'
| | | \-[ALIAS] 's'
| | +-[JOIN] 'join'
| | | +-[LEFT] 'left'
| | | +-[DOT] '.'
| | | | +-[IDENT] 's'
| | | | \-[IDENT] 'analysisSamples'
| | | \-[ALIAS] 'ass'
| | \-[JOIN] 'join'
| | +-[LEFT] 'left'
| | +-[DOT] '.'
| | | +-[IDENT] 'ass'
| | | \-[IDENT] 'reads'
| | \-[ALIAS] 'read'
| \-[SELECT] 'select'
| \-[DOT] '.'
| +-[IDENT] 's'
| \-[WEIRD_IDENT] 'order'
+-[WHERE] 'where'
| \-[AND] 'and'
| +-[AND] 'and'
| | +-[AND] 'and'
| | | +-[EQ] '='
| | | | +-[DOT] '.'
| | | | | +-[IDENT] 'read'
| | | | | \-[IDENT] 'locked'
| | | | \-[TRUE] 'true'
| | | \-[IS_NOT_NULL] 'is not null'
| | | \-[DOT] '.'
| | | +-[IDENT] 's'
| | | \-[IDENT] 'dateRelease'
| | \-[IS_NULL] 'is null'
| | \-[DOT] '.'
| | +-[IDENT] 's'
| | \-[IDENT] 'dateCompleted'
| \-[IN] 'in'
| +-[DOT] '.'
| | +-[DOT] '.'
| | | +-[IDENT] 'ass'
| | | \-[IDENT] 'plate'
| | \-[IDENT] 'product'
| \-[IN_LIST] 'inList'
| \-[QUERY] 'query'
| +-[SELECT_FROM] 'SELECT_FROM'
| | +-[FROM] 'from'
| | | \-[RANGE] 'RANGE'
| | | +-[DOT] '.'
| | | | +-[DOT] '.'
| | | | | +-[DOT] '.'
| | | | | | +-[DOT] '.'
| | | | | | | +-[DOT] '.'
| | | | | | | | +-[DOT] '.'
| | | | | | | | | +-[IDENT] 'de'
| | | | | | | | | \-[IDENT] 'kiendl_solutions'
| | | | | | | | \-[IDENT] 'laborax'
| | | | | | | \-[IDENT] 'modules'
| | | | | | \-[IDENT] 'sequencing'
| | | | | \-[IDENT] 'model'
| | | | \-[IDENT] 'AnalysisType'
| | | \-[ALIAS] 'at'
| | \-[SELECT] 'select'
| | \-[ELEMENTS] 'elements'
| | \-[DOT] '.'
| | +-[IDENT] 'at'
| | \-[IDENT] 'products'
| \-[WHERE] 'where'
| \-[IN] 'in'
| +-[COLON] ':'
| | \-[IDENT] 'workgroup'
| \-[IN_LIST] 'inList'
| \-[ELEMENTS] 'elements'
| \-[DOT] '.'
| +-[IDENT] 'at'
| \-[IDENT] 'workgroups'
+-[GROUP] 'group'
| \-[DOT] '.'
| +-[DOT] '.'
| | +-[IDENT] 's'
| | \-[WEIRD_IDENT] 'order'
| \-[IDENT] 'id'
\-[ORDER] 'order'
+-[DOT] '.'
| +-[DOT] '.'
| | +-[IDENT] 's'
| | \-[WEIRD_IDENT] 'order'
| \-[IDENT] 'dateRelease'
\-[ASCENDING] 'asc'

throwQueryException() : no errors
query() << begin, level = 1
FromClause{level=1} : de.kiendl_solutions.laborax.modules.sequencing.model.Sample (s) -> sample0_
Resolved : s -> sample0_.orderPosition_id
getDataType() : analysisSamples -> org.hibernate.type.BagType(de.kiendl_solutions.laborax.modules.sequencing.model.Sample.analysisSamples)
createEntityAssociation() : One to many - path = s.analysisSamples role = de.kiendl_solutions.laborax.modules.sequencing.model.Sample.analysisSamples associatedEntityName = de.kiendl_soluti
ons.laborax.modules.sequencing.model.AnalysisSample
FromClause{level=1} : de.kiendl_solutions.laborax.modules.sequencing.model.AnalysisSample (ass) -> analysissa1_
addJoinByPathMap() : s.analysisSamples -> laborax_sequencing_analysissample analysissa1_
dereferenceCollection() : Created new FROM element for s.analysisSamples : laborax_sequencing_analysissample analysissa1_
Resolved : s.analysisSamples -> .
createFromJoinElement() : -- join tree --
\-[JOIN_FRAGMENT] FromElement: 'laborax_sequencing_analysissample analysissa1_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=ass,role=de
.kiendl_solutions.laborax.modules.sequencing.model.Sample.analysisSamples,tableName=laborax_sequencing_analysissample,tableAlias=analysissa1_,colums={sample0_.orderPosition_id ,className=de
.kiendl_solutions.laborax.modules.sequencing.model.AnalysisSample}}

Resolved : ass -> analysissa1_.id
getDataType() : reads -> org.hibernate.type.BagType(de.kiendl_solutions.laborax.modules.sequencing.model.AnalysisSample.reads)
createEntityAssociation() : One to many - path = ass.reads role = de.kiendl_solutions.laborax.modules.sequencing.model.AnalysisSample.reads associatedEntityName = de.kiendl_solutions.labora
x.modules.sequencing.model.Read
FromClause{level=1} : de.kiendl_solutions.laborax.modules.sequencing.model.Read (read) -> reads2_
addJoinByPathMap() : ass.reads -> laborax_sequencing_read reads2_
dereferenceCollection() : Created new FROM element for ass.reads : laborax_sequencing_read reads2_
Resolved : ass.reads -> .
createFromJoinElement() : -- join tree --
\-[JOIN_FRAGMENT] FromElement: 'laborax_sequencing_read reads2_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=read,role=de.kiendl_soluti
ons.laborax.modules.sequencing.model.AnalysisSample.reads,tableName=laborax_sequencing_read,tableAlias=reads2_,colums={analysissa1_.id ,className=de.kiendl_solutions.laborax.modules.sequenc
ing.model.Read}}

Resolved : s -> sample0_.orderPosition_id
getDataType() : order -> org.hibernate.type.ManyToOneType(de.kiendl_solutions.laborax.model.AbstractOrder)
dereferenceEntityJoin() : generating join for order in de.kiendl_solutions.laborax.modules.sequencing.model.Sample {no alias} parent = [ {null} ]
FromClause{level=1} : de.kiendl_solutions.laborax.model.AbstractOrder (no alias) -> abstractor3_
addJoinByPathMap() : s.order -> laborax_order abstractor3_
Resolved : s.order -> sample0_2_.order_id
Resolved : read -> reads2_.id
getDataType() : locked -> org.hibernate.type.BooleanType@1f5205c
Resolved : read.locked -> reads2_.locked
Resolved : s -> sample0_.orderPosition_id
getDataType() : dateRelease -> org.hibernate.type.TimestampType@b4b0a4
Resolved : s.dateRelease -> sample0_2_.dateRelease
Resolved : s -> sample0_.orderPosition_id
getDataType() : dateCompleted -> org.hibernate.type.TimestampType@b4b0a4
Resolved : s.dateCompleted -> sample0_2_.dateCompleted
Resolved : ass -> analysissa1_.id
ExceptionHandler caught this exception:
de.kiendl_solutions.laborax.exceptions.InfrastructureException: org.hibernate.QueryException: could not resolve property: plate of: de.kiendl_solutions.laborax.modules.sequencing.model.Anal
ysisSample [select s.order from de.kiendl_solutions.laborax.modules.sequencing.model.Sample s left join s.analysisSamples ass left join ass.reads as read where read.locked = true and s.date
Release is not null and s.dateCompleted is null and ass.plate.product in (select elements(at.products) from de.kiendl_solutions.laborax.modules.sequencing.model.AnalysisType as at where :wo
rkgroup in elements(at.workgroups)) group by s.order.id order by s.order.dateRelease asc]
at de.kiendl_solutions.laborax.modules.sequencing.dao.SampleDAO.findOrdersWithLockedSamplesByWorkgroup(Unknown Source)
at de.kiendl_solutions.laborax.modules.sequencing.struts.WAnalysisLockedSamplesListAction.execute(Unknown Source)
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:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at de.kiendl_solutions.laborax.session.WorkflowSessionFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:188)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at de.kiendl_solutions.laborax.persistance.HibernateFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.QueryException: could not resolve property: plate of: de.kiendl_solutions.laborax.modules.sequencing.model.AnalysisSample [select s.order from de.kiendl_solutions.l
aborax.modules.sequencing.model.Sample s left join s.analysisSamples ass left join ass.reads as read where read.locked = true and s.dateRelease is not null and s.dateCompleted is null and a
ss.plate.product in (select elements(at.products) from de.kiendl_solutions.laborax.modules.sequencing.model.AnalysisType as at where :workgroup in elements(at.workgroups)) group by s.order.
id order by s.order.dateRelease asc]
at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:37)
at org.hibernate.persister.entity.BasicEntityPersister.toType(BasicEntityPersister.java:1094)
at org.hibernate.persister.collection.AbstractCollectionPersister.toType(AbstractCollectionPersister.java:1126)
at org.hibernate.hql.ast.FromElementType.getPropertyType(FromElementType.java:273)
at org.hibernate.hql.ast.FromElement.getPropertyType(FromElement.java:349)
at org.hibernate.hql.ast.DotNode.getDataType(DotNode.java:474)
at org.hibernate.hql.ast.DotNode.prepareLhs(DotNode.java:208)
at org.hibernate.hql.ast.DotNode.resolve(DotNode.java:166)
at org.hibernate.hql.ast.DotNode.resolveFirstChild(DotNode.java:133)
at org.hibernate.hql.ast.HqlSqlWalker.lookupProperty(HqlSqlWalker.java:324)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:767)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:859)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.inLhs(HqlSqlBaseWalker.java:3815)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3514)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1405)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1333)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:599)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:404)
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)
... 31 more


Top
 Profile  
 
 Post subject: Where's your Plate mapping?
PostPosted: Mon Nov 07, 2005 9:14 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
That is SO hard to read. Can you use the code tag next time?

The exception (or at least the first exception, my head was hurting by the time I got that far so I didn't check to see if there are more exceptions) is complaining about a missing getPlate() method in your AnalysisSample class. It's not complaining about the one-to-many Plate in your AnalysisSample mapping. So: do you have a public Plate getPlate(); method defined for the AnalysisSample class?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 9:44 pm 
Newbie

Joined: Mon Nov 07, 2005 6:51 pm
Posts: 2
Thank you for the quick reply.

Sorry, I'll use code tags next time. This was my first post here.

I tried access="field" when i posted here, but i have public getters and setters as well and it doesn't work neither.

In my post there are only two exceptions at the end.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 9:52 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Fair enough. On closer reading, Hibernate is complaining about a missing getplate() method, not getPlate(). Is your accessor in AnalysisSample called getPlate()? If it is, then change the name="plate" attribute in your many-to-one to name="Plate".


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.