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: Hibernate does not set the object retrived?
PostPosted: Mon Mar 06, 2006 4:11 pm 
Newbie

Joined: Tue Dec 27, 2005 1:32 pm
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.1

Mapping documents:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="org.ny.estat.metadata.model" catalog="DTXRQ003">
<!-- catalog="DTXRQ003" -->
<class name="SeriesDefinition" table="XRV_SER_DFN_CTL" lazy="false">
<composite-id name="seriesDefinitionIdentity" class="org.ny.estat.metadata.model.SeriesDefinitionIdentity">
<key-property name="seriesName" column="ser_id_r" />
<key-property name="effectiveDate" column="efct_d" type="org.ny.estat.om.persist.hibernate.types.SimpleDateType"/>
<key-property name="districtCode" column="dist_c" />
</composite-id>

<bag name="items" lazy="false" table="XRV_SER_DFN_ITMS">
<key not-null="false">
<column name="ser_id_r"></column>
<column name="efct_d"></column>
<column name="dist_c"></column>
</key>
<one-to-many class="ItemDefinition"></one-to-many>
</bag>



</class>
</hibernate-mapping>




<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="org.ny.estat.metadata.model" catalog="DTXRQ003">
<class name="ItemDefinition" table="XRV_SER_DFN_ITMS" >

<composite-id name="itemDefinitionIdentity" class="org.ny.estat.metadata.model.ItemDefinitionIdentity">
<key-property name="seriesName" column="ser_id_r" />
<key-property name="effectiveDate" column="efct_d" type="org.ny.estat.om.persist.hibernate.types.SimpleDateType"/>
<key-property name="districtCode" column="dist_c" />
<key-property name="itemCode" column="itm_id_c" />
</composite-id>

<property name="itemDescription" column="ITM_DESC_X" />
<property name="itemType" column="ITM_TYP_C" />
<property name="mdrm4Code" column="MDRM_C" />
<!-- <property name="itemSequence" formula="((MAX(MIC_CTL_SEQ_R) -1) * 220) + MAX(MIC_ITM_SEQ_R) - MAX(ITM_OCRN_R) + 1" />
<property name="occurrenceCount" formula="MAX(ITM_OCRN_R)" /> -->
<!-- <many-to-one name="seriesDefinition" update="false" insert="false">
<column name="ser_id_r" ></column>
<column name="efct_d"></column>
<column name="dist_c"></column>
</many-to-one> -->
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

select
seriesdefi0_.ser_id_r as ser1_0_0_,
seriesdefi0_.efct_d as efct2_0_0_,
seriesdefi0_.dist_c as dist3_0_0_
from
DTXRQ003.XRV_SER_DFN_CTL seriesdefi0_
where
seriesdefi0_.ser_id_r=?
and seriesdefi0_.efct_d=?
and seriesdefi0_.dist_c=?
Hibernate:
select
items0_.ser_id_r as ser1_1_,
items0_.efct_d as efct2_1_,
items0_.dist_c as dist3_1_,
items0_.itm_id_c as itm4_1_,
items0_.ser_id_r as ser1_1_0_,
items0_.efct_d as efct2_1_0_,
items0_.dist_c as dist3_1_0_,
items0_.itm_id_c as itm4_1_0_,
items0_.ITM_DESC_X as ITM5_1_0_,
items0_.ITM_TYP_C as ITM6_1_0_,
items0_.MDRM_C as MDRM7_1_0_
from
DTXRQ003.XRV_SER_DFN_ITMS items0_
where
items0_.ser_id_r=?
and items0_.efct_d=?
and items0_.dist_c=?


Now the problem is that the second query fetches 181 rows. Tested it from the db. Also if I put a system out in the default construtor of ItemDefinition objects constructs it spits the out.println 181 times.

But the object in the SeriesDefinition of type items is empty. Have no clue how to procesd.

Thanx in advnace.


Top
 Profile  
 
 Post subject: And these are my objects
PostPosted: Mon Mar 06, 2006 5:17 pm 
Newbie

Joined: Tue Dec 27, 2005 1:32 pm
Posts: 3
I thought putting objects would help for an answer ....


/*

* Created on Feb 22, 2006
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/

package org.ny.estat.metadata.model;


import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.frb.ny.util.date.SimpleDate;

/**
* @author b1bxpc0
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/



public class ItemDefinitionIdentity implements Serializable {


private String seriesName = null;

private String districtCode = null;

private SimpleDate effectiveDate = null;

private String itemCode = null;

public ItemDefinitionIdentity(){
System.out.println("Identenies being constructed");
}


public String getDistrictCode() {
return districtCode;
}


public void setDistrictCode(String districtCode) {
this.districtCode = districtCode;
}


public SimpleDate getEffectiveDate() {
return effectiveDate;
}


public void setEffectiveDate(SimpleDate effectiveDate) {
this.effectiveDate = effectiveDate;
}


public String getItemCode() {
return itemCode;
}


public void setItemCode(String itemCode) {
this.itemCode = itemCode;
}


public String getSeriesName() {
return seriesName;
}


public void setSeriesName(String seriesName) {
this.seriesName = seriesName;
}


public boolean equals(Object obj) {
if (obj instanceof ItemDefinitionIdentity == false) {
return false;
}
if (this == obj) {
return true;
}
ItemDefinitionIdentity otherIdi = (ItemDefinitionIdentity) obj;
return new EqualsBuilder().appendSuper(super.equals(obj)).append(
getDistrictCode(), otherIdi.getDistrictCode()).append(
getEffectiveDate(), otherIdi.getEffectiveDate()).append(
getItemCode(), otherIdi.getItemCode()).append(getSeriesName(),
otherIdi.getSeriesName()).isEquals();
}

public int hashCode() {
return new HashCodeBuilder(17, 37).append(getDistrictCode()).append(
getEffectiveDate()).append(getItemCode()).append(
getSeriesName()).toHashCode();
}
}



/*
* Created on Feb 22, 2006
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.ny.estat.metadata.model;

import java.io.Serializable;

/**
* @author b1bxpc0
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ItemDefinition implements Serializable{

public ItemDefinition(){

}

// identity column
ItemDefinitionIdentity itemDefinitionIdentity = null;

/**
* @return Returns the itemDefinitionIdentity.
*/
public ItemDefinitionIdentity getItemDefinitionIdentity() {
return itemDefinitionIdentity;
}
/**
* @param itemDefinitionIdentity The itemDefinitionIdentity to set.
*/
public void setItemDefinitionIdentity(
ItemDefinitionIdentity itemDefinitionIdentity) {
this.itemDefinitionIdentity = itemDefinitionIdentity;
}
}



/*
* Created on Feb 18, 2006
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.frb.ny.estat.metadata.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


/**
* @author b1bxpc0
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class SeriesDefinition implements Serializable{

// identity column
private SeriesDefinitionIdentity seriesDefinitionIdentity ;

// relationship columns

private List items = new ArrayList();

/**
* @return Returns the items.
*/
public List getItems() {
return items;
}
/**
* @param items The items to set.
*/
public void setItems(List items) {
this.items = items;
}
/**
* @return Returns the seriesDefinitionIdentity.
*/
public SeriesDefinitionIdentity getSeriesDefinitionIdentity() {
return seriesDefinitionIdentity;
}
/**
* @param seriesDefinitionIdentity The seriesDefinitionIdentity to set.
*/
public void setSeriesDefinitionIdentity(
SeriesDefinitionIdentity seriesDefinitionIdentity) {
this.seriesDefinitionIdentity = seriesDefinitionIdentity;
}
}





/*
* Created on Feb 18, 2006
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.ny.estat.metadata.model;

import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.frb.ny.util.date.SimpleDate;


/**
* @author b1bxpc0
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class SeriesDefinitionIdentity implements Serializable{

private SimpleDate effectiveDate = null;
private String seriesName = null;
private String districtCode = null;
public int hashCode() {

return new HashCodeBuilder(17, 37).
append(getEffectiveDate()).
append(getSeriesName()).
append(getDistrictCode()).
toHashCode();
}

public boolean equals(Object obj) {
if (obj instanceof SeriesDefinitionIdentity == false) {
return false;
}
if (this == obj) {
return true;
}
SeriesDefinitionIdentity inObj = (SeriesDefinitionIdentity) obj;
return new EqualsBuilder()
.appendSuper(super.equals(obj))
.append(getEffectiveDate(), inObj.getEffectiveDate())
.append(getSeriesName(), inObj.getSeriesName())
.append(getDistrictCode(), inObj.getDistrictCode())
.isEquals();
}


/**
* @return Returns the districtCode.
*/
public String getDistrictCode() {
return districtCode;
}
/**
* @param districtCode The districtCode to set.
*/
public void setDistrictCode(String districtCode) {
this.districtCode = districtCode;
}
/**
* @return Returns the effectiveDate.
*/
public SimpleDate getEffectiveDate() {
return effectiveDate;
}
/**
* @param effectiveDate The effectiveDate to set.
*/
public void setEffectiveDate(SimpleDate effectiveDate) {
this.effectiveDate = effectiveDate;
}
/**
* @return Returns the seriesName.
*/
public String getSeriesName() {
return seriesName;
}
/**
* @param seriesName The seriesName to set.
*/
public void setSeriesName(String seriesName) {
this.seriesName = seriesName;
}
}


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.