-->
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.  [ 2 posts ] 
Author Message
 Post subject: collection roloe misuderstanding
PostPosted: Fri Feb 02, 2007 6:42 pm 
Beginner
Beginner

Joined: Wed Oct 29, 2003 10:43 am
Posts: 38
Location: Chicago
<?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="net.gainsystems.common.clientserverbatch.hibernate.skul.LocationByItemNumberAndStockIndicatorNotEqualN">
<subselect>
Select
item_no
From skul left join skul2 on skul.skul_no = skul2.skul_no
WHERE skul2.stock_ind != 'N'
GROUP By item_no
</subselect>

<synchronize table="skul"/>
<synchronize table="skul2"/>


<id column="item_no" length="65" name="itemNumber" type="string"/>


<set name="locationSetForItemNumber"
lazy="false"
inverse="true"
cascade="none">

<key column="item_no"/>
<many-to-many
class="net.gainsystems.common.clientserverbatch.hibernate.skul.Location"/>

<loader query-ref="locationSetForItemNumberLoadQuery"/>
</set>
<sql-query name="locationSetForItemNumberLoadQuery">
<load-collection alias="loc"
role="LocationByItemNumberAndStockIndicatorNotEqualN.locationSetForItemNumber"/>
<return alias="loc" class="net.gainsystems.common.clientserverbatch.hibernate.skul.Location"/>
SELECT
{loc.*}
FROM ( SELECT loc_inner.loc_no from skul inner join location loc_inner
where sku.item_no = :item_no
group By loc_inner.loc_no ) loc_group INNER JOIN location loc
WHERE loc.loc_no = loc_group.loc_no
</sql-query>
</class>
</hibernate-mapping>

<?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="net.gainsystems.common.clientserverbatch.hibernate.skul.Location"
table="Location">
<id column="loc_no" name="locationNumber" length="8" type="string">
<generator class="assigned"/>
</id>
<property column="loc_name" length="28" name="locationName" type="string"/>
<property column="Cubage_Thresh" precision="19" scale="7" name="cubageThreshold" type="double"/>
<property column="Weight_Thresh" precision="19" scale="5" name="weightThreshold" type="double"/>
<property column="Next_Replenish" precision="23" scale="3" name="nextReplenishment" type="timestamp"/>
<property column="Second_Replen" precision="23" scale="3" name="secondReplenishment" type="timestamp"/>
<property column="Days_Btwn_Replen" length="3" name="daysBetweenReplenishment" type="short"/>
</class>
</hibernate-mapping>


i get the following error:
02-02-2007 16:38:54:363 DEBUG QueryPlanCache getNativeSQLQueryPlan unable to locate native-sql query plan in cache; generating (SELECT
{loc.*}
FROM ( SELECT loc_inner.loc_no from skul inner join location loc_inner
where sku.item_no = :item_no
group By loc_inner.loc_no ) loc_group INNER JOIN location loc
WHERE loc.loc_no = loc_group.loc_no)
02-02-2007 16:38:54:378 ERROR SessionFactoryImpl <init> Error in named query: net.gainsystems.common.clientserverbatch.hibernate.skul.LocationByItemNumberAndStockIndicatorNotEqualN.locationSetForItemNumberLoadQuery
org.hibernate.MappingException: Unknown collection role: LocationByItemNumberAndStockIndicatorNotEqualN.locationSetForItemNumber
at org.hibernate.impl.SessionFactoryImpl.getCollectionPersister(SessionFactoryImpl.java:522)
at org.hibernate.loader.custom.SQLQueryReturnProcessor.addCollection(SQLQueryReturnProcessor.java:136)
at org.hibernate.loader.custom.SQLQueryReturnProcessor.processCollectionReturn(SQLQueryReturnProcessor.java:172)
at org.hibernate.loader.custom.SQLQueryReturnProcessor.processReturn(SQLQueryReturnProcessor.java:101)
at org.hibernate.loader.custom.SQLQueryReturnProcessor.process(SQLQueryReturnProcessor.java:87)
at org.hibernate.loader.custom.SQLCustomQuery.<init>(SQLCustomQuery.java:105)
at org.hibernate.engine.query.NativeSQLQueryPlan.<init>(NativeSQLQueryPlan.java:20)
at org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:113)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:410)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:328)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at net.gainsystems.common.serverbatch.hibernate.HibernateSessionFactory.<init>(HibernateSessionFactory.java:201)
at net.gainsystems.server.DataManager.initialize(DataManager.java:115)
at net.gainsystems.server.GainsGuiServer.staticInit(GainsGuiServer.java:270)
at net.gainsystems.server.GainsGuiServer.main(GainsGuiServer.java:60)
02-02-2007 16:38:54:378 FATAL DataManager initialize Error occurred while intializing DataManager
org.hibernate.HibernateException: Errors in named queries: net.gainsystems.common.clientserverbatch.hibernate.skul.LocationByItemNumberAndStockIndicatorNotEqualN.locationSetForItemNumberLoadQuery
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:339)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at net.gainsystems.common.serverbatch.hibernate.HibernateSessionFactory.<init>(HibernateSessionFactory.java:201)
at net.gainsystems.server.DataManager.initialize(DataManager.java:115)
at net.gainsystems.server.GainsGuiServer.staticInit(GainsGuiServer.java:270)
at net.gainsystems.server.GainsGuiServer.main(GainsGuiServer.java:60)

I would appreciate any help figuring out what a valif role is.
In the examples they seem like the enclosing classs and the set name

_________________
LET IT BE :)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 04, 2007 5:47 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Can you use <return> and <load-collection> in the same named query? I've never done that, perhaps that's what's wrong?

_________________
Code tags are your friend. Know them and use them.


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