-->
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: Persistent Bag is empty
PostPosted: Wed Feb 17, 2010 1:30 pm 
Newbie

Joined: Wed Feb 17, 2010 1:16 pm
Posts: 1
I am trying to pull data from two tables PRODUCT_TYPE and PRODUCT_TYPE_ATTR table with one-to-many relationship through Persistent Bag. I am able to query the items in the first table (PRODUCT_TYPE) but the bag for each item is always null.

Here are the mapping files and the class. Can someone shed some light?

Thanks

Product Type Mapping

<hibernate-mapping>
<class name="com.ab.cb.fg.ProductType" table="PRODUCT_TYPE">

<id name="productType" column="PRODUCT_TYPE">
</id>

<property name="insertDate" column="INSERT_DATE"/>
<property name="description" column="DESCRIPTION"/>
<property name="replFlg" column="A_FLG"/>

<bag name="productTypeAttrs" cascade="all" inverse="true">
<key column="PRODUCT_TYPE"/>
<one-to-many class="com.ab.cb.fg.ProductTypeAttr"/>
</bag>

</class>
</hibernate-mapping>

ProductTypeAttr Mapping

<hibernate-mapping>
<class name="com.ab.cb.fg.ProductTypeAttr" table="PRODUCT_TYPE_ATTR">
<composite-id name="productTypeAttrPK"
class="com.ab.cb.fg.ProductTypeAttr$ProductTypeAttrPK">
<key-property name="productType" column="PRODUCT_TYPE" type="string"/>
<key-property name="attribute" column="ATTRIBUTE" type="string"/>
</composite-id>
<property name="insertDate" column="INSERT_DATE"/>
<property name="description" column="DESCRIPTION"/>
<property name="attributeSelection" column="ATTRIBUTE_SELECTION"/>
<property name="seq" column="SEQ"/>
</class>
</hibernate-mapping>


ProductTypeAttr Class

public class ProductTypeAttr implements Serializable {


private ProductTypeAttrPK prodTypeAttrPK;
/**
* Primary key
*/
private ProductTypeAttrPK productTypeAttrPK;

/**
* Attribute insertDate.
*/
private Timestamp insertDate;

/**
* Attribute description.
*/
private String description;
/**
* Attribute description.
*/
private String attribute;
/**
* Attribute attributeSelection.
*/
private String attributeSelection;

/**
* Attribute seq.
*/
private Short seq;


/**
* Get the primary key
*/
public ProductTypeAttrPK getProductTypeAttrPK() {
return this.productTypeAttrPK;
}

/**
* set the primary key
*/
public void setProductTypeAttrPK(ProductTypeAttrPK productTypeAttrPK) {
this.productTypeAttrPK = productTypeAttrPK;
}





/**
* @return insertDate
*/
public Timestamp getInsertDate() {
return insertDate;
}

/**
* @param insertDate new value for insertDate
*/
public void setInsertDate(Timestamp insertDate) {
this.insertDate = insertDate;
}

/**
* @return description
*/
public String getDescription() {
return description;
}

/**
* @param description new value for description
*/
public void setDescription(String description) {
this.description = description;
}

/**
* @return attributeSelection
*/
public String getAttributeSelection() {
return attributeSelection;
}

/**
* @param attributeSelection new value for attributeSelection
*/
public void setAttributeSelection(String attributeSelection) {
this.attributeSelection = attributeSelection;
}

/**
* @return seq
*/
public Short getSeq() {
return seq;
}

/**
* @param seq new value for seq
*/
public void setSeq(Short seq) {
this.seq = seq;
}

public void setAttribute(String attribute) {
this.attribute = attribute;
}

public String getAttribute() {
return attribute;
}

public void setProdTypeAttrPK(ProductTypeAttr.ProductTypeAttrPK prodTypeAttrPK) {
this.prodTypeAttrPK = prodTypeAttrPK;
}

public ProductTypeAttr.ProductTypeAttrPK getProdTypeAttrPK() {
return prodTypeAttrPK;
}


/**
* <p>Composite primary key for table PRODUCT_TYPE_ATTR</p>
*/
public static class ProductTypeAttrPK implements Serializable {

/**
* Attribute productType
*/
private ProductType productType;


/**
* Attribute attribute
*/
private String attribute;

/**
* get productType
*/
public ProductType getProductType() {
return this.productType;
}

/**
* set productType
*/
public void setProductType(ProductType productType) {
this.productType = productType;
}
/**
* Return attribute
*/
public String getAttribute() {
return attribute;
}

/**
* @param attribute new value for attribute
*/
public void setAttribute(String attribute) {
this.attribute = attribute;
}

/**
* calculate hashcode
*/
public int hashCode()
{
//TODO : implement this method
return super.hashCode();
}

/**
* equals method
*/
public boolean equals(Object object)
{
//TODO : implement this method
return super.equals(object);
}

}

}


Top
 Profile  
 
 Post subject: Re: Persistent Bag is empty
PostPosted: Sun Apr 17, 2011 10:33 pm 
Newbie

Joined: Wed Apr 13, 2011 5:18 pm
Posts: 3
did you find out what your problem was. my problem is that the bag gets populated on my test database but i get an empty bag when run against my production database. both databases are identical and i have verified that the data is there. Please let me know if you have a solution.

Thanks


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.