Hi everyone,

 Ihave a class named AbstractUser which is:

/**
*
* @hibernate.class table="user"
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public abstract class AbstractUser implements ValueObject {

protected PK primaryKey;

protected String password;

public PrimaryKey getPrimaryKey() {
return getPK();
}

public void setPrimaryKey(PrimaryKey pk) {
this.primaryKey = (PK)pk;
}

public void setPrimaryKey(Serializable pk) {
if (pk instanceof Collection) {
Collection c = (Collection)pk;
Iterator it = c.iterator();
setPrimaryKey(new PK(((Long)it.next()).longValue(), (String)it.next()));
} else {
}
}

/**
* @hibernate.id generator-class="assigned"
*/
private PK getPK(){
return this.primaryKey;
}

/**
* @hibernate.property
*/
public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public static class PK implements PrimaryKey {

private long code;
private String login;

public PK() {
this(-1,null);
}

public PK(long code, String login) {
this.code = code;
this.login = login;
}

/**
* @hibernate.property
*/
public long getCode() {
return this.code;
}

/**
* @hibernate.property
*/
public String getLogin(){
return this.login;
}

public boolean equals(Object o){
AbstractUser.PK pk = (AbstractUser.PK) o;
if (this.code == pk.getCode() && this.login.equals(pk.getLogin())){
return true;
}
else{
return false;
}
}
}

}

After running hibernatedoclet task it s mapped to:

<hibernate-mapping>
<class
name="com.smartprice.eb.valueobject.AbstractUser"
table="user"
dynamic-update="false"
dynamic-insert="false"


<composite-id name="PK" class="com.smartprice.eb.valueobject.AbstractUser.PK"

<key-property
name="code"
type="long"
column="code"
/>

<key-property
name="login"
type="java.lang.String"
column="login"
/>

</composite-id>

...

Shouldn't the class name be "com.smartprice.eb.valueobject.AbstractUser$PK", as PK is an inner class of AbstractUser? If i run the Hibernate hbm2ddl tool it says that it cant find the "com.smartprice.eb.valueobject.AbstractUser" class. If i change it to "com.smartprice.eb.valueobject.AbstractUser$PK", it works fine.

Speaking of composite keys, i have a class name admin which extends from AbstractUser. Which tag should i use to create the following mapping:

<joined-subclass name="com.smartprice.eb.valueobject.Admin" dynamic-update="false" dynamic-insert="false">
<key>
<column name="code"/>
<column name="login"/>
<key/>
</joined-subclass>


regards,

Leorazuk


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to