-->
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: Cannot get primary key from object in <composite-element&
PostPosted: Wed May 10, 2006 2:38 pm 
Newbie

Joined: Wed Apr 20, 2005 6:57 pm
Posts: 9
Location: San Diego, Ca
Ok I got the composite-elements to work within an id bag and let me say they are awesome. So fast to load and they still work similar to entity objects. Excellent. The only problem I'm having is the Primary keys are not being set in my java object. All the other fields are set no problem. And I have played with it to the best of my ability. Middlegen will not generate the java object for the Projectcompound class listed below, so I had to write it by hand. Perhaps I wrote it incorrectly. The mapping works extremely well and everything else is fine, I just can't get the pk so it's difficult to update the object. Is this by design? Am I doing something lame? Thanks.

Hibernate version:
Hibernate 2

Mapping documents:


<idbag name="projectcompounds"
lazy="true"
table="PROJECTCMPD"
order-by="STARTDATE asc " >
<collection-id type="java.lang.Long" column="PROJECTCMPDID">
<generator class="sequence">
<param name="sequence">PROJECTCMPD_PKSEQ</param>
</generator>
</collection-id>
<key column="PROJECTID" />
<composite-element class="blah.blah.Projectcompound" >
<many-to-one
name="kstructure"
class="blah.blah.Kstructure"
not-null="true"
>
<column name="SID" />
</many-to-one>
<many-to-one
name="project"
class="blah.blah.Datadictionary"
not-null="true"
>
<column name="TYPE_LD" />
</many-to-one>

<property
name="mechanism"
type="java.lang.String"
column="MECHANISM"
length="255"
/>
<property
name="classs"
type="java.lang.String"
column="CLASS"
length="255"
/>
<property
name="name"
type="java.lang.String"
column="NAME"
length="255"
/>
<property
name="startreason"
type="java.lang.String"
column="STARTREASON"
length="4000"
/>
<property
name="endreason"
type="java.lang.String"
column="ENDREASON"
length="4000"
/>
<property
name="startdate"
type="java.sql.Timestamp"
column="STARTDATE"
length="3"
/>
<property
name="enddate"
type="java.sql.Timestamp"
column="ENDDATE"
length="3"
/>
</composite-element>
</idbag>




Name and version of the database you are using:
Oracle 9i

CODE:

public class Projectcompound implements Serializable {

private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Projectcompound.class);
private String mechanism = null;
private String name = null;
private String classs = null;
private String endreason = null;
private String startreason = null;

private Date startdate;
private Date enddate;

private blah.blah.Kstructure kstructure;
private blah.blah.Project project;
private blah.blah.Datadictionary typeLd;

private long projectcmpdid = -1;

public Projectcompound() {
logger.info( "888888888888888 88888 888 calling CTOR()" );
}
public Projectcompound( long projectcmpdid ) {
logger.info( "888888888888888 88888 888 calling CTOR( " +projectcmpdid+" )" );
this.projectcmpdid = projectcmpdid;
}
public void setProjectcmpdid( long projectcmpdid ) {
logger.info( "888888888888888 88888 888 calling setProjectcmpdid with [" +projectcmpdid+"]" );
this.projectcmpdid = projectcmpdid;
}
public long getProjectcmpdid() {
return this.projectcmpdid;
}
public void setMechanism( String mechanism ) {
logger.info( "888888888888888 88888 888 calling setMechanism with [" +mechanism+"]" );
this.mechanism = mechanism;
}
public String getMechanism() {
return this.mechanism;
}

public void setName( String name ) {
logger.info( "888888888888888 88888 888 calling setName with [" +name+"]" );
this.name = name;
}
public String getName() {
return this.name;
}

public void setClasss( String classs ) {
logger.info( "888888888888888 88888 888 calling setClasss with [" +classs+"]" );
this.classs = classs;
}
public String getClasss() {
return this.classs;
}

public void setEndreason( String endreason ) {
logger.info( "888888888888888 88888 888 calling setEndreason with [" +endreason+"]" );
this.endreason = endreason;
}
public String getEndreason() {
return this.endreason;
}

public void setStartreason( String startreason ) {
logger.info( "888888888888888 88888 888 calling setStartreason with [" +startreason+"]" );
this.startreason = startreason;
}
public String getStartreason() {
return this.startreason;
}

public void setStartdate( Date startdate ) {
logger.info( "888888888888888 88888 888 calling setStartdate with [" +startdate+"]" );
this.startdate = startdate;
}
public Date getStartdate() {
return this.startdate;
}

public void setEnddate( Date enddate ) {
this.enddate = enddate;
}
public Date getEnddate() {
return this.enddate;
}

public void setKstructure( Kstructure kstructure ) {
this.kstructure = kstructure;
}
public Kstructure getKstructure() {
return this.kstructure;
}

public void setProject( Project project ) {
this.project = project;
}
public Project getProject() {
return this.project;
}

public void setTypeLd( Datadictionary typeLd ) {
this.typeLd = typeLd;
}
public Datadictionary getTypeLd() {
return this.typeLd;
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 10, 2006 4:18 pm 
Newbie

Joined: Wed Apr 20, 2005 6:57 pm
Posts: 9
Location: San Diego, Ca
I also upgraded to the lates middlegen to no avail. And I matched the primary key type java.lang.Long to the java object, still nothing. If anyone has a sample idbag xml and matching java class that works I'd love to see it. Also I am using the what I believe to be the latest version 2 of hibernate. We have not upgraded to 3 yet.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 1:12 pm 
Newbie

Joined: Wed Apr 20, 2005 6:57 pm
Posts: 9
Location: San Diego, Ca
Ok so I tried to cheat by adding another field that would also be set by the PK column called componentPK. No dice! On start up verification Hibernate busted me with a mapping exception:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'WAKHibernateSessionFactory' defined in ServletContex
t resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is net.sf.hibernate.MappingException: Repeated
column in mapping for collection: com.kalypsys.domain.persistenceobjects.wak.Project.projectcompounds column: PROJECTCMPDID
net.sf.hibernate.MappingException: Repeated column in mapping for collection: com.kalypsys.domain.persistenceobjects.wak.Project.projectcomp
ounds column: PROJECTCMPDID



<idbag name="projectcompounds"
lazy="true"
table="PROJECTCMPD"
order-by="STARTDATE asc " >
<collection-id type="java.lang.Long" column="PROJECTCMPDID">
<generator class="sequence">
<param name="sequence">PROJECTCMPD_PKSEQ</param>
</generator>
</collection-id>
<key column="PROJECTID" />
<composite-element class="com.kalypsys.domain.persistenceobjects.wak.Projectcompound" >
<property
name="componentPK"
type="java.lang.Long"
column="PROJECTCMPDID"
/>
<many-to-one
name="kstructure"
class="com.kalypsys.domain.persistenceobjects.wak.Kstructure"
not-null="true"
>
<column name="SID" />
</many-to-one>
<many-to-one
name="project"
class="com.kalypsys.domain.persistenceobjects.wak.Datadictionary"
not-null="true"
>
<column name="TYPE_LD" />
</many-to-one>

<property
name="mechanism"
type="java.lang.String"
column="MECHANISM"
length="255"
/>
<property
name="classs"
type="java.lang.String"
column="CLASS"
length="255"
/>
<property
name="name"
type="java.lang.String"
column="NAME"
length="255"
/>
<property
name="startreason"
type="java.lang.String"
column="STARTREASON"
length="4000"
/>
<property
name="endreason"
type="java.lang.String"
column="ENDREASON"
length="4000"
/>
<property
name="startdate"
type="java.sql.Timestamp"
column="STARTDATE"
length="3"
/>
<property
name="enddate"
type="java.sql.Timestamp"
column="ENDDATE"
length="3"
/>
</composite-element>
</idbag>


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.