Hi:
Can anyone provide me an example of incrementing the "id" when the mapping file has it defined as assigned? I'm having problems understanding the IncrementGenerator.generate() method and how this is used with the following mapping file and PO.
Thanks, Alex.
Hibernate version:
2.1.6
Mapping documents:
Code:
<hibernate-mapping>
<class
name="com.telus.ccs.adminRouting.model.po.SkillsetSiteAssociationAdmin
"
table="SkillsetSiteAssociationAdmin"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="id"
type="java.lang.Integer"
>
<generator class="assigned">
</generator>
</id>
<property
name="skillsetName"
type="java.lang.String"
update="false"
insert="true"
access="property"
column="skillsetName"
length="40"
not-null="true"
/>
<property
name="siteName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="siteName"
length="30"
not-null="true"
/>
<property
name="percentage"
type="java.lang.Integer"
update="true"
insert="true"
access="property"
column="percentage"
length="10"
not-null="true"
/>
<property
name="phoneNumber"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="phoneNumber"
length="11"
not-null="true"
/>
<property
name="configName"
type="java.lang.String"
update="false"
insert="true"
access="property"
column="configName"
not-null="true"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-SkillsetSiteAssociationAdmin.xml
containing the additional properties and place it in your merge di
r.
-->
</class>
</hibernate-mapping>
Java PO:Code:
public class SkillsetSiteAssociationAdmin extends BasePO {
private static AppLogger logger = AppLogger.getLogger(
SkillsetSiteAssociationAdmin.class);
private Integer id;
private String skillsetName;
private String siteName;
private Integer percentage;
private String phoneNumber;
private String configName;
/**
* @hibernate.id
* generator-class="increment"
*/
public Integer getId() {
return this.id;
}
/**
* @hibernate.property
* not-null="true"
* length="40"
*/
public String getSkillsetName() {
return this.skillsetName;
}
/**
* @hibernate.property
* not-null="true"
* length="30"
*/
public String getSiteName() {
return this.siteName;
}
/**
* @hibernate.property
* not-null="true"
* length="10"
*/
public Integer getPercentage() {
return this.percentage;
}
/**
* @hibernate.property
* not-null="true"
* length="11"
*/
public String getPhoneNumber() {
return this.phoneNumber;
}
/**
* @hibernate.property
* not-null="true"
* length="40"
*/
public String getConfigName() {
return this.configName;
}
public void setId(Integer id) {
this.id = id;
}
public void setSkillsetName(String skillsetName) {
this.skillsetName = skillsetName;
}
public void setSiteName(String siteName) {
this.siteName = siteName;
}
public void setPercentage(Integer percentage) {
this.percentage = percentage;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public void setConfigName (String configName) {
this.configName = configName;
}
}
Code between sessionFactory.openSession() and session.close():
n/a
Full stack trace of any exception that occurs:
n/a
Name and version of the database you are using:
Oracle 9
The generated SQL (show_sql=true):
n/a
Debug level Hibernate log excerpt: