hello guys
my class have this definition for the variable that represents the composite
key
[code]
/**
* @hibernate.id generator-class="increment"
[b] * @MyNotes <key-property name="idnumero" column="idnumero"/>
<key-property name="tipoAlmacen" column="tipoAlmacen"/>[/b]
*/
public AlmacenId getAlmacenId() {
return almacenId;
}
[/code]
thisi s the class that represents the composite key
[code]
mport java.io.Serializable;
public class AlmacenId implements Serializable{
private static final long serialVersionUID = 1L;
private String idnumero;
private String tipoAlmacen;
public AlmacenId(String idnumero, String tipoAlmacen){
this.idnumero=idnumero;
this.tipoAlmacen=tipoAlmacen;
}
public String getIdnumero() {
return idnumero;
}
public void setIdnumero(String idnumero) {
this.idnumero = idnumero;
}
public String getTipoAlmacen() {
return tipoAlmacen;
}
public void setTipoAlmacen(String tipoAlmacen) {
this.tipoAlmacen = tipoAlmacen;
}
public boolean equals(Object o){
if(this==o) return true;
if(o==null) return false;
if( !( o instanceof AlmacenId ) ) return false;
final AlmacenId almacenId = (AlmacenId) o;
if( !idnumero.equals(almacenId.getIdnumero()))
return false;
if(!tipoAlmacen.equals(almacenId.getTipoAlmacen()))
return false;
return true;
}
public int hashcode(){
int result;
result = idnumero.hashcode();
result = 29*result +tipoAlmacen.hashcode();
return result;
}
}
[/code]
i must declare @hibernate.id by exigence/demand of xdoclet , but no appear
in the hbm.xml file, weird? or this is normal?
but i saw that xdoclet automatically creates this in the hbm.xml
[code]
<composite-id
name="almacenId"
class="com.manolo.test.AlmacenId"
>
</composite-id>
[/code]
how i conclude this??
well if i delete or comment thwse methods equals(Object o) and int
hashcode()
and try with xdoclet create the mapping files i recieve a lot of errors
by the moment i dont know how use xdoclet to create the correct way, like
[code]
<composite-id
name="almacenId"
class="com.manolo.test.AlmacenId"
>
<key-property name="idnumero" column="idnumero"/>
<key-property name="tipoAlmacen" column="tipoAlmacen"/>
</composite-id>
[/code]
so how i can have the application working???,
after the create the hbm, i copy manually the 2 <key-property
from my getAlmacenId() in the @MyNotes part
in the hbm file in the class folder
so if can help me how do this automatically , pls let me know
thanks for advanced
--
View this message in context:
http://www.nabble.com/how-xdoclet-can-create-%3Ccomposite-id------tf3356651.html#a9335689
Sent from the xdoclet-user mailing list archive at Nabble.com.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
xdoclet-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user