[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1235?page=c...
]
Steve Ebersole closed HHH-1235.
-------------------------------
Closing stale resolved issues
Is Composition possible with Hibernate?
---------------------------------------
Key: HHH-1235
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1235
Project: Hibernate Core
Issue Type: Task
Components: core
Affects Versions: 3.0.5
Environment: Oracle 9i,Hibernate 3.0.5, Eclipse 3.1
Reporter: chaitanya sanjay karmarakr
Original Estimate: 24h
Remaining Estimate: 24h
I have a POJO Client.java.I want this class to compose an object of another class
ClientAddress; which is a POJO class too. A *.hbm.xml is present for both.
package com.hibernate.tutorial.classes;
public class Client{
private Long clientNo;
private String clientName;
private Long clientOfficeId;
private String clientStatusCode;
private String clientFundCode;
private ClientAddressUsage clientAddressUsagePOC;
public ClientAddressUsage getClientAddressUsage() {
return clientAddressUsage;
}
public void setClientAddressUsage(ClientAddressUsage clientAddressUsage) {
this.clientAddressUsage = clientAddressUsage;
}
public String getClientFundCode() {
return clientFundCode;
}
public void setClientFundCode(String clientFundCode) {
this.clientFundCode = clientFundCode;
}
public String getClientName() {
return clientName;
}
public void setClientName(String clientName) {
this.clientName = clientName;
}
public Long getClientNo() {
return clientNo;
}
public void setClientNo(Long clientNo) {
this.clientNo = clientNo;
}
public Long getClientOfficeId() {
return clientOfficeId;
}
public void setClientOfficeId(Long clientOfficeId) {
this.clientOfficeId = clientOfficeId;
}
public String getClientStatusCode() {
return clientStatusCode;
}
public void setClientStatusCode(String clientStatusCode) {
this.clientStatusCode = clientStatusCode;
}
}
Now, for acheiving composition is the Client.hbm.xml correct:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.tutorial.hibernate.classes.ClientPOC"
table="CLIENT_POC" >
<composite-id >
<key-property name="clientNo" type="java.lang.Long"
column="CLIENT_NO"/>
<key-property name="clientOfficeId" type="java.lang.Long"
column="CLIENT_OFFICE_ID"/>
</composite-id>
<property name="clientName" type="java.lang.String">
<column name="CLIENT_NAME" length="40" />
</property>
<property name="clientStatusCode"
type="java.lang.String">
<column name="CLIENT_STATUS_CODE" length="1" />
</property>
<property name="clientFundCode"
type="java.lang.String">
<column name="CLIENT_FUND_CODE" length="3" />
</property>
<property name="clientAddressUsagePOC"
type="java.lang.Object"
access="com.tutorial.hibernate.classes.ClientAddressUsagePOC" >
</property>
</class>
</hibernate-mapping>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira