-->
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: Extending a Hibernate Object (newbie question)
PostPosted: Tue Sep 20, 2005 11:25 am 
Beginner
Beginner

Joined: Tue Sep 20, 2005 11:01 am
Posts: 25
I have a simple application in which there is a Hibernate class for each table.

To make the application easier to maintain I want to extend the Hibernate classes and put the application specific code in the subclasses. Ideally I would like to make the Hibernate classes abstract.

When I add application specific code I will modify the subclass and not the Hibernate class. This way I can regenerate (middlegen) the Hibernate class without overwriting any application specific code.

Each Hibernate class will be extended by one and only one subclass so issues related to polymorphism and things of that nature are not an issue.

Is there an easy way to accomplish this?

Thanks,

Matt


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 7:10 pm 
Regular
Regular

Joined: Mon Aug 22, 2005 1:11 pm
Posts: 50
Location: Pasadena, CA
hibernate.subclass


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 9:55 am 
Beginner
Beginner

Joined: Tue Sep 20, 2005 11:01 am
Posts: 25
I believe you put me on the right track but I'm still running into problems. I added the following bolded code to my .hbm.xml file

<class
name="gov.epa.otaq.verify.hibernate.McCert"
table="MC_CERT" discriminator-value="conditional"
select-before-update="true"
>

......

<subclass name="gov.epa.otaq.verify.hibernate.McCertV"
discriminator-value="non-conditional"
dynamic-update="true" dynamic-insert="true"/>


.......
</class>

When I run the following code I get the error "Could not execute JDBC batch update" :

Code:
       try {
            Criteria crit = hibernateSession.createCriteria(McCert.class);
            crit.add(Expression.eq("fuelType", fuelType));
            mcCertV = (McCertV) crit.uniqueResult();
        } catch (HibernateException he) {
            System.out.println("Could not search for McCert by fuelType: " +
he);
            throw (he);
        }



Am I missing something ?

Thanks,
Matt


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 12:14 pm 
Regular
Regular

Joined: Mon Aug 22, 2005 1:11 pm
Posts: 50
Location: Pasadena, CA
try getting rid of the discriminator-value entry

and dynamic-update="false"
dynamic-insert'"=false"

Just a shot.


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.