Hello,
The following hbm.xml is generated by XDoclet. But it failed to export SQL?
I don't know where caused the problem. It failed when generated with the Player.hbm.xml !!!!
The goal.hbm.xml is no problem, but the player.hbm.xml failed.
Is there any problem in defining those XDoclet tag? Those tags I defined as same as the example in the xdoclet samples.
Regard,
Eric
Code:
/**
* Player class
*
*
* @hibernate.class
* table="player"
* polymorphism="explicit"
* mutable="false"
*
* @struts.form
* extends="org.apache.struts.validator.ValidatorForm"
* include-all="true"
*/
public class Player extends BaseObject {
protected int playerId;
protected String playerName;
protected boolean playerStatus;
protected List goals;
public void setPlayerId(int playerId) {
this.playerId = playerId;
}
/**
* @hibernate.id
* column="playerId"
* generator-class="native"
*/
public int getPlayerId() {
return playerId;
}
public void setPlayerName(String playerName) {
this.playerName = playerName;
}
/**
* @hibernate.property
* column="playerName"
* not-null="true"
*/
public String getPlayerName() {
return playerName;
}
public void setPlayerStatus(boolean playerStatus) {
this.playerStatus = playerStatus;
}
/**
* @hibernate.property
* column="playerStatus"
* not-null="true"
*/
public boolean getPlayerStatus() {
return playerStatus;
}
public void setGoals(List goals) {
this.goals = goals;
}
/**
* @hibernate.list
* lazy="true"
* inverse="true"
* cascade="all"
* @hibernate.jcs-cache
* usage="read-write"
* @hibernate.collection-key
* column="playerId"
* @hibernate.collection-index
* column="playerPos"
* @hibernate.collection-one-to-many
* class="com.echows.football.model.Goal"
* @return List
*/
public List getGoals() {
return goals;
}
}
Code:
/**
* Goal class
*
*
* @hibernate.class
* table="goal"
*
* @struts.form
* extends="org.apache.struts.validator.ValidatorForm"
* include-all="true"
*/
public class Goal {
protected Date goalDate;
protected Player player;
protected int goalQuantity;
protected int goalId;
public void setGoalId(int goalId) {
this.goalId = goalId;
}
/**
* @hibernate.id
* generator-class="native"
*/
public int getGoalId() {
return goalId;
}
public void setGoalDate(Date goalDate) {
this.goalDate = goalDate;
}
/**
* @hibernate.property
* not-null="true"
*/
public Date getGoalDate() {
return goalDate;
}
public void setGoalQuantity(int goalQuantity) {
this.goalQuantity = goalQuantity;
}
/**
* @hibernate.property
* not-null="true"
*/
public int getGoalQuantity() {
return goalQuantity;
}
public void setPlayer(Player player) {
this.player = player;
}
/**
*
* @hibernate.many-to-one
* column="playerId"
* not-null="true"
* constraint="true"
*/
public Player getPlayer() {
return player;
}
}
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="com.echows.football.model.Player"
table="player"
polymorphism="explicit"
dynamic-update="false"
dynamic-insert="false"
mutable="false"
>
<id
name="playerId"
column="playerId"
type="int"
>
<generator class="native">
</generator>
</id>
<property
name="playerName"
type="java.lang.String"
update="true"
insert="true"
column="playerName"
not-null="true"
/>
<property
name="playerStatus"
type="boolean"
update="true"
insert="true"
column="playerStatus"
not-null="true"
/>
<list
name="goals"
lazy="true"
inverse="true"
cascade="all"
>
<jcs-cache
usage="read-write"
/>
<key
column="playerId"
/>
<index
column="playerPos"
/>
<one-to-many
class="com.echows.football.model.Goal"
/>
</list>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Player.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="com.echows.football.model.Goal"
table="goal"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="goalId"
column="goalId"
type="int"
>
<generator class="native">
</generator>
</id>
<property
name="goalDate"
type="java.util.Date"
update="true"
insert="true"
column="goalDate"
not-null="true"
/>
<property
name="goalQuantity"
type="int"
update="true"
insert="true"
column="goalQuantity"
not-null="true"
/>
<many-to-one
name="player"
class="com.echows.football.model.Player"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="playerId"
not-null="true"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Goal.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>