-->
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: inheritance troubles
PostPosted: Mon Jul 10, 2006 11:07 am 
Newbie

Joined: Thu Jul 06, 2006 9:54 am
Posts: 8
hi

i'm trying to map a subclass i use the table-per-subclass strategy the super class maps ok but when i wanna map the subclass i get this errors


Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not update: [org.hibernate.inheritance.test.FacturaCompra#4]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2222)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:84)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1007)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:354)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at salida.testing.main(testing.java:35)
Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid parameter binding(s).
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.validateParameters(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.validateParameters(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.preImplExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2208)
... 12 more


could you please help as quickly as you can????


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 10, 2006 11:57 am 
Beginner
Beginner

Joined: Wed Sep 21, 2005 11:52 am
Posts: 43
It's difficult to tell what your problem is without more information, specifically a trimmed down example of your mapping files, when the exception occurs, and the versions of Hibernate, Java, and your underlying database.

Check out the suggestions on how to ask for help.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 11, 2006 9:24 am 
Newbie

Joined: Thu Jul 06, 2006 9:54 am
Posts: 8
ok sorry i am using hibernate tools 3.1.0 beta5, JDk5
and my hierrachy is like this

class A{
//attributes

//getters and setters
}

class B extendes A{

//it owns methods
}

and when i try to do this

B b = new B();
b.setSTH();


session.save(b);
tx.commit();
session.close();
iget that error

However when i do the same for the class A can can persit it could anybody tellme waht i must do?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 11, 2006 12:16 pm 
Beginner
Beginner

Joined: Wed Sep 21, 2005 11:52 am
Posts: 43
You still did not post your mapping files so I cannot give specific advice. Look at section 9.1.2 in the reference doc. All of Chapter 9 would be good to read as it describes various ways to deal with inheritance. In case you don't have the doc here is the table per subclass example copied from the doc:

Code:
<class name="Payment" table="PAYMENT">
  <id name="id" type="long" column="PAYMENT_ID">
     <generator class="native"/>
  </id> <property name="amount" column="AMOUNT"/>
    ...
  <joined-subclass name="CreditCardPayment" table="CREDIT_PAYMENT">
    <key column="PAYMENT_ID"/>
    <property name="creditCardType" column="CCTYPE"/>
    ...
  </joined-subclass>
  <joined-subclass name="CashPayment" table="CASH_PAYMENT">
    <key column="PAYMENT_ID"/>
    ...
  </joined-subclass>
  <joined-subclass name="ChequePayment" table="CHEQUE_PAYMENT">
    <key column="PAYMENT_ID"/>
    ...
  </joined-subclass>
</class>


I have not actually used this approach. I used table per class hierarchy, which works fine for me. Since the example does not show the class definitions it's a bit unclear how they look. The confusing issue to me is the id property. It appears that the id in the superclass is used for each of the subclasses. There's a similar example in the book Hibernate in Action that shows different ids for each subclass.

I suggest you play around with this example and use hbm2ddl to generate the DDL for the tables. Then go the other way and generate the Java. That should be instructive.

Good luck.


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.