-->
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: Classes inheritance - strange behaviour of <joined-subcla
PostPosted: Thu Oct 11, 2007 3:39 am 
Newbie

Joined: Mon Sep 24, 2007 9:35 am
Posts: 4
Hi,
I have problem with classes inheritance. I have table Register. Sometimes I don't need all it's columns, so I decided to map this table twice. I've created class
RegisterBasic {

RegisterBasic(){}

protected int registerNumber;
protected UserBasic owner;

public int getRegisterNumber() {
return registerNumber;
}

public void setRegisterNumber(int registerNumber) {
this.registerNumber = registerNumber;
}

public UserBasic getOwner() {
return owner;
}

public void setOwner(UserBasic owner) {
this.owner=(UserBasic)owner.clone();
}


}

And it's mapinig document looks like this:

<hibernate-mapping>
<class name="connections.register.RegisterBasic" table="REGISTER">
<id name="registerNumber" column="REGISTER_NUM" type="integer">
<generator class="assigned"/>
</id>
<many-to-one name="owner" column="USER_ID" class="connections.user.UserBasic" not-null="true" foreign-key="FK_REG_USER"/>
</class>
</hibernate-mapping>


And than, it's classes extention:

class Register extends RegisterBasic{

Register(){}
private UnitClass unitClass;
public UnitClass getUnitClass() {
return unitClass;
}

public void setUnitClass(UnitClass unitClass) {
this.unitClass=(UnitClass)unitClass.clone();
}

And it's mapping:
}

<hibernate-mapping>
<joined-subclass name="connections.register.Register" extends="connections.register.RegisterBasic">
<key column="registerNumber"/>
<many-to-one name="unitClass" column="UNIT_CLASS" class="connections.fund.UnitClass" not-null="true" foreign-key="FK_REG_UNIT"/>
</joined-subclass>
</hibernate-mapping>


When I haven't used extention and just define again all variables and their functions again in class Register and in iRegister.hbm.xml file everything worked fine. But when I use this notation query
Query q = getSession().createQuery(" from Register " );
List result =q.list()
returns empty list. I really don't understand this. What is wrong with this notation?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 12, 2007 5:54 am 
Newbie

Joined: Mon Sep 24, 2007 9:35 am
Posts: 4
Nobody used Hibernate to class which is an extention of another class? I would appreciate any help or advice.


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.