-->
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.  [ 3 posts ] 
Author Message
 Post subject: fetch all subclass
PostPosted: Sat Oct 30, 2004 2:33 pm 
Beginner
Beginner

Joined: Wed Jan 28, 2004 2:06 am
Posts: 33
Hi

Is there a way to get all the subclass ? I have a discriminator on the parent class. When i do a query like

createSQLQuery("SELECT {c.*} from Animal{c} where name LIKE :name","c",Animal.class );

I am getting only Animal class. No cat or camel is retrieved. Is there a way to get all ?


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 30, 2004 2:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It should work. What is your mapping strategy?


Top
 Profile  
 
 Post subject: fetch all subclass
PostPosted: Sat Oct 30, 2004 3:11 pm 
Beginner
Beginner

Joined: Wed Jan 28, 2004 2:06 am
Posts: 33
/**
* @hibernate.class table="TAAttrDef" discriminator-value="0"
* @hibernate.discriminator column="attribType" type="int"
*/
public class TAAttrDef implements Serializable, Comparable, Cloneable
{

///////////////////////////////////////
// attributes
public TAAttrDef()
{
}
private String name = "";
private int id;
private int attribType = 0;


public static final int NORMAL_ATTRIBUTE = 0;
public static final int PASSWORD_ATTRIBUTE = 1;
public static final int ENTITLEMENT_ATTRIBUTE = 2;


public int hashCode()
{
if (name == null)
{
return 0;
}

return name.hashCode();

}

public boolean equals(Object obj)
{
if ((obj == null) || (name == null))
{
return false;
}

if (!(obj instanceof TAAttrDef))
{
return false;
}

TAAttrDef rhs = (TAAttrDef) obj;
return name.equals(rhs.getName());
}

public int compareTo(Object obj)
{
if ((obj == null) || (name == null))
{
return -1;
}

if (!(obj instanceof TAAttrDef))
{
return -1;
}

TAAttrDef rhs = (TAAttrDef) obj;
return name.compareTo(rhs.getName());
}

/**
* Does ...
*
* @hibernate.property column="name" type="string" length="64" not-null="false" unique="true"
* @return
*/
public String getName()
{
return name;
} // end getName

/**
* Does ...
*
*
* @param _name
*/
public void setName(String _name)
{
name = _name;
} // end setName

/**
* Does ...
*
* @hibernate.id column="id" type="int"
* generator-class="com.trulogica.truaccess.idgen.util.HibernateIdGenerator"
* unsaved-value="0"
* @hibernate.generator-param name="TableName" value="TAAttrDef"
* @return
*/
public int getId()
{
return id;
} // end getId

/**
* Does ...
*
*
* @param _id
*/
public void setId(int _id)
{
id = _id;
} // end setId


/**
* Does ... */
public int getAttribType()
{
return attribType;
} // end getAttribType

/**
* Does ...
*
*
* @param _attribType
*/
public void setAttribType(int _attribType)
{
attribType = _attribType;
} // end setAttribType

} // end TAAttrDef














/**
* * @hibernate.subclass name="com.trulogica.truaccess.attribute.model.TAEntitlementAttr" discriminator-value="2"
*/
public class TAEntitlementAttr extends TAAttrDef implements java.io.Serializable {
public TAEntitlementAttr() {
super();
setAttribType(TAAttrDef.ENTITLEMENT_ATTRIBUTE);
}
} // end TAEntitlementAttr













public class TAPasswdAttr extends TAAttrDef implements java.io.Serializable {
public TAPasswdAttr() {
super();
setAttribType(TAAttrDef.PASSWORD_ATTRIBUTE);
}
} // end TAPasswdAttr







Then i have the stmt

q = session.createSQLQuery("SELECT {c.*} from TAAttrDef {c} where name LIKE :name","c",TAAttrDef.class );

with the intention to get all instance of TAAttrDef (TAPasswordDef, TAEnt....). I don't get TAPasswordDef or TAEnt !!!


Can somebody point out the reason. There should be a way out to get all sub classes.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.