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: Problem with Inheritence - Noob question
PostPosted: Sat Oct 13, 2007 9:04 am 
Newbie

Joined: Tue Mar 20, 2007 4:40 am
Posts: 6
Location: India
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.x

Mapping documents:
<?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 = "com.jd.hibernate.associations.Users" table = "TEST_JD_USERS" discriminator-value="Users">
<id name = "id" column = "ID" type = "int">
<generator class = "increment"/>
</id>
<!-- following column need not be defined as property in pojo -->
<discriminator column = "Users_Type" type = "java.lang.String" />
<property name = "userType" type = "java.lang.String" column = "USERTYPE" />
<property name = "password" type = "java.lang.String" column = "PASSWORD" />
<property name = "firstName" type = "java.lang.String" column = "FIRSTNAME" />
<property name = "lastName" type = "java.lang.String" column = "LASTNAME" />
<property name = "email" type = "java.lang.String" column = "EMAIL" />
<property name = "homePhone" type = "java.lang.String" column = "HOMEPHONE" />
<property name = "workPhone" type = "java.lang.String" column = "WORKPHONE" />
</class>


<subclass name = "com.jd.hibernate.associations.PresentingUser"
extends ="com.jd.hibernate.associations.Users" discriminator-value="PresentingUser" >
<property name = "company" type = "java.lang.String" column = "COMPANY" />
<property name = "companyUrl" type = "java.lang.String" column = "COMPANYURL" />
<property name = "companyState" type = "java.lang.String" column = "COMPANYSTATE" />
<property name = "companyStreetAddress" type="java.lang.String" column="COSTREETADDR" />
<property name = "companyZipCode" type="int" column="COZIPCODE" />
</subclass>

<subclass name = "com.jd.hibernate.associations.ParticipatingUser"
extends ="com.jd.hibernate.associations.Users" discriminator-value="ParticipatingUser" >
<property name = "eventParticipatingIn" type="java.lang.String" column="EVENTPARTICIPATEIN" />
</subclass>

<subclass name = "com.jd.hibernate.associations.NormalUser"
extends ="com.jd.hibernate.associations.Users" discriminator-value="NormalUser" >
</subclass>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
session = sessionFactory.openSession();
tx = session.beginTransaction();
tx.begin();
ParticipatingUser pUser = new ParticipatingUser();
pUser.setEmail("navnith@asd.com");
pUser.setEventParticipatingIn("EventParticipating in");
pUser.setFirtName("asd");
pUser.setHomePhone(0303);
pUser.setLastName("M");
pUser.setPassword("asd");
pUser.setUserType("Super");
pUser.setWorkPhone(131311);
session.save(pUser);


tx.commit();
session.close();


Full stack trace of any exception that occurs:
Exception in thread "main" org.hibernate.PropertyNotFoundException: Could not find a getter for firstName in class com.jd.hibernate.associations.NormalUser
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:275)
at org.hibernate.mapping.Property.getGetter(Property.java:272)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:247)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:125)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at com.jd.hibernate.associations.TestUsers.main(TestUsers.java:14)

Name and version of the database you are using:
Ms Sql Server 2000


I am a Noob.I have RTFM.
I am trying to do a simple table per class hierachy association.
My previous sample worked. However in this one, I have one class which has no body or properties but just extends a parent class. I am not even calling this code. However this gives a problem.
I have a base class User. and sub classes as X,Y,Z.
Z does not have any body. I am calling setters on class Y. and during running... the above given is the problem. I would be grateful if some one could point out the wrong in the code ( or the approach ?)

thanks


Top
 Profile  
 
 Post subject: silly !
PostPosted: Mon Oct 15, 2007 1:17 am 
Newbie

Joined: Tue Mar 20, 2007 4:40 am
Posts: 6
Location: India
Thanks everyone, I solved it.
I dunno how, but this time, I copy pasted the variables from my User class into my hbm.xml, and it worked. guess a silly space some where.

Cheers..


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.