-->
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: Exception in mapping file (StringIndexOutOfBoundsException)
PostPosted: Wed Nov 22, 2006 7:51 am 
Newbie

Joined: Tue Dec 27, 2005 10:39 am
Posts: 9
Hi
I get the exception below when my <subclass> element has a single <component> element like in my mapping file below.

If i add a <property> element along with the <component>, i don't get any exceptions. The problem is that i don't want to add a column to my table for a dummy property. When I declare a formula in my property
<property name="dummy" formula="...."/> i get the same error.


Hibernate version: 3.0.5

Mapping documents:

Code:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="folder">


           
   <subclass name="Sheet" extends="SheetWithResults">   
      <join table="SHEET" fetch="select">
      
     <key column="IDTSHEET"/>

           
          <component name="subscriptions" class="CollectionHolder">
             <bag name="items" lazy="true" cascade="all-delete-orphan">         
              <key column="SHEETID"/>
              <one-to-many class="Subscription"/>
            </bag>
          </component>
       </join>
   </subclass>
</hibernate-mapping>








Full stack trace of any exception that occurs:
Code:
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -2
   at java.lang.String.substring(String.java:1444)
   at java.lang.String.substring(String.java:1411)
   at org.hibernate.persister.entity.AbstractEntityPersister.renderSelect(AbstractEntityPersister.java:2595)
   at org.hibernate.persister.entity.SingleTableEntityPersister.generateSequentialSelect(SingleTableEntityPersister.java:624)
   at org.hibernate.persister.entity.SingleTableEntityPersister.postInstantiate(SingleTableEntityPersister.java:673)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:274)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 22, 2006 10:34 am 
Beginner
Beginner

Joined: Mon Nov 13, 2006 8:22 am
Posts: 28
looking in the code I can see where the exception occurs but I can't explain the problem:

Code:
//now render the select clause
SelectFragment selectFragment = createSelect( columnNumbers, formulaNumbers );
      
//now tie it all together
Select select = new Select( getFactory().getDialect() );
select.setSelectClause( selectFragment.toFragmentString().[b]substring( 2 ) [/b]);


hope this helps a little


appart from this I do see a problem in the DOCTYPE of your xml; it should be:

Quote:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

regards,
Stijn


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.