Bonjour à tous,
voilà mon soucis...
J'ai un bean qui a un id composé comme suit :
package com.fnac.piloting.treasury.bean.batch;
import com.fnac.piloting.treasury.bean.AbstractBusinessBean;
/**
* RubricTicketAdmin : rubric parameters to feed rubrics for treasury day
*
* @author
*
* @hibernate.class table="RUBRIC_TICKET_ADMIN"
*/
public class RubricTicketAdmin extends AbstractBusinessBean {
/** RubricTicketAdminId */
private RubricTicketAdminId rubricTicketAdminId;
/** administrative operation code */
private String _adminOperation;
/** payment mode */
private String _paymentMode;
/**
* @return the sequence
*
* @return value
*
* @hibernate.property column="ADMIN_OPERATION"
*/
public String getAdminOperation() {
return _adminOperation;
}
/**
* @param operation the _adminOperation to set
*/
public void setAdminOperation(String operation) {
_adminOperation = operation;
}
/**
* @return the sequence
*
* @return value
*
* @hibernate.property column="PAYMENT_MODE"
*/
public String getPaymentMode() {
return _paymentMode;
}
/**
* @param mode the _paymentMode to set
*/
public void setPaymentMode(String mode) {
_paymentMode = mode;
}
/**
* return the property value
*
* @return value
*
* @hibernate.id generator-class="assigned"
*/
public RubricTicketAdminId getRubricTicketAdminId() {
return rubricTicketAdminId;
}
/**
* @param rubricTicketAdminId the rubricTicketAdminId to set
*/
public void setRubricTicketAdminId(RubricTicketAdminId rubricTicketAdminId) {
this.rubricTicketAdminId = rubricTicketAdminId;
}
}
la classe Id est :
package com.fnac.piloting.treasury.bean.batch;
import java.io.Serializable;
import com.fnac.piloting.treasury.bean.Rubric;
/**
* Id class for RubricTicketAdmin, made because Hibernate needs an id
*
* @author
*/
public class RubricTicketAdminId implements Serializable {
/** RubricId */
private Rubric rubric;
/** Sequence */
private Integer sequence;
/**
* @return the rubric
* @hibernate.many-to-one
* column="RUBRIC_ID"
* not-null="true"
*/
public Rubric getRubric() {
return rubric;
}
/**
* @param rubric the rubric to set
*/
public void setRubric(Rubric rubric) {
this.rubric = rubric;
}
/**
* @return the sequence
*
* @return value
*
* @hibernate.property column="RUBRIC_SEQUENCE"
*/
public Integer getSequence() {
return sequence;
}
/**
* @param sequence the sequence to set
*/
public void setSequence(Integer sequence) {
this.sequence = sequence;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
final int PRIME = 31;
int result = 1;
result = PRIME * result + ((rubric == null) ? 0 : rubric.hashCode());
result = PRIME * result + ((sequence == null) ? 0 : sequence.hashCode());
return result;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final RubricTicketAdminId other = (RubricTicketAdminId) obj;
if (rubric == null) {
if (other.rubric != null)
return false;
} else if (!rubric.equals(other.rubric))
return false;
if (sequence == null) {
if (other.sequence != null)
return false;
} else if (!sequence.equals(other.sequence))
return false;
return true;
}
}
maintenant je voudrai faire une liaison "on-to-many" avec une atre classe, voilà le code :
/*
* Last modified by: $Author: mmeyer $
*
* Copyright (c) 2004 Fnac S.A.
*/
package com.fnac.piloting.treasury.bean;
import java.util.Collections;
import java.util.Date;
import java.util.Set;
/**
* Category to classify treasury amounts (mostly a payment mean)
*
* @author Frédéric Esnault
*
* @hibernate.class table="RUBRIC"
*/
public class Rubric extends AbstractBusinessBean {
/** "Cheque" rubric code */
public static final String RUBRIC_CHEQUE = "CHEQUE";
/** debit type */
public static final String DEBIT_TYPE = "D";
/** credit type */
public static final String CREDIT_TYPE = "C";
/** "CA Net des remises" rubric code */
public static final String RUBRIC_CANETR = "CANETR";
/** "Clients arrhes reçus" rubric code */
public static final String RUBRIC_CLARRE = "CLARRE";
/** "Clients arrhes déduits" rubric code */
public static final String RUBRIC_CLARDE = "CLARDE";
/** "Ventes différées perçues" rubric code */
public static final String RUBRIC_VDIFFP = "VDIFFP";
/** "Fonds de caisse fermeture" rubric code */
public static final String RUBRIC_FONDSF = "FONDSF";
/** "Fonds de caisse ouverture" rubric code */
public static final String RUBRIC_FONDSO = "FONDSO";
/** "Ventes différées éditées" rubric code */
public static final String RUBRIC_VDIFFE = "VDIFFE";
/** "2e déclic" rubric code */
public static final String RUBRIC_2EDECL = "2EDECL";
/** "Régularisations" rubric code */
public static final String RUBRIC_REGUL = "REGUL";
/** "Ventes Clients Administratifs" rubric code */
public static final String RUBRIC_VADMIN = "VADMIN";
/** technical key to identify the object */
private Integer _rubricId;
/** sequence number giving the presentation order */
private Integer _sequence;
/** source param */
// private RubricSourceParam _rubricSourceParam;
/** set of RubricAccount instances */
private Set _rubricAccounts = Collections.EMPTY_SET;
/** short code to identiy the rubric */
private String _code;
/** long label explaining the rubric */
private String _label;
/** type of rubric : debit (D) or credit (C) */
private String _type;
/** flag to specify if rubric is editable */
private boolean _editable;
/** sequence number giving the output entry order */
private Integer _outputEntrySequence;
/** End date for rubric, to stop treatment in batch */
private Date _endDate;
/** RubricTicketAdmin */
private Set rubricTicketAdmin = Collections.EMPTY_SET;
/** is source hardcoded */
private boolean _hardCoded;
/** country - multiple country problematic */
//private Country _country;
private EnseignePays _cPy;
/**
* Constructor
*/
public Rubric() {
super();
}
/**
* sets the code
*
* @param string the code
*/
public void setCode(String string) {
_code = string;
}
/**
* returns the code
*
* @return the code
*
* @hibernate.property column="CODE"
*/
public String getCode() {
return _code;
}
/**
* sets the editable flag
*
* @param b a boolean value
*/
public void setEditable(boolean b) {
_editable = b;
}
/**
* returns if rubric is editable
*
* @return true if editable
*
* @hibernate.property column="EDITABLE" type="yes_no"
*/
public boolean isEditable() {
return _editable;
}
/**
* sets the label
*
* @param string the label
*/
public void setLabel(String string) {
_label = string;
}
/**
* returns the label
*
* @return the label
*
* @hibernate.property column="LABEL"
*/
public String getLabel() {
return _label;
}
/**
* set the associated rubric accounts
*
* @param set set
*/
public void setRubricAccounts(Set set) {
_rubricAccounts = set;
}
/**
* returns the associated rubric accounts
*
* @return the rubric accounts
*
* @hibernate.set lazy="true" cascade="all-delete-orphan"
* @hibernate.collection-key column="RUBRIC_ID"
* @hibernate.collection-one-to-many
* class="com.fnac.piloting.treasury.bean.RubricAccount"
*/
public Set getRubricAccounts() {
return _rubricAccounts;
}
/**
* sets the id (key)
*
* @param integer the id
*/
public void setRubricId(Integer integer) {
_rubricId = integer;
}
/**
* returns the id (key)
*
* @return value
*
* @hibernate.id generator-class="sequence" unsaved-value="null"
* column="RUBRIC_ID"
* @hibernate.generator-param name="sequence" value="TREASURY_SEQUENCE"
*
* */
public Integer getRubricId() {
return _rubricId;
}
/**
* @return the rubricTicketAdmin
*
* @hibernate.set lazy="true" cascade="all-delete-orphan"
* @hibernate.collection-key column="RUBRIC_ID"
* @hibernate.collection-one-to-many
* class="com.fnac.piloting.treasury.bean.batch.RubricTicketAdmin"
*/
public Set getRubricTicketAdmin() {
return rubricTicketAdmin;
}
/**
* @param rubricTicketAdmin the rubricTicketAdmin to set
*/
public void setRubricTicketAdmin(Set rubricTicketAdmins) {
rubricTicketAdmin = rubricTicketAdmins;
} /**
* set the sequence
*
* @param integer the sequence
*/
public void setSequence(Integer integer) {
_sequence = integer;
}
/**
* returns the sequence
*
* @return the sequence
*
* @hibernate.property column="SEQUENCE"
*/
public Integer getSequence() {
return _sequence;
}
/**
* sets the type
*
* @param string the type
*/
public void setType(String string) {
_type = string;
}
/**
* returns the type
*
* @return the type
*
* @hibernate.property column="TYPE"
*/
public String getType() {
return _type;
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
if (!(obj instanceof Rubric)) {
return false;
}
return getRubricId() != null
&& getRubricId().equals(((Rubric) obj).getRubricId());
}
/**
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
if (getRubricId() == null) {
return -1;
}
return getRubricId().intValue();
}
/**
* returns the sequence
*
* @return the sequence
*
* @hibernate.property column="OUTPUT_ENTRY_SEQUENCE"
*/
public Integer getOutputEntrySequence() {
return _outputEntrySequence;
}
/**
* set the sequence
*
* @param integer the sequence
*/
public void setOutputEntrySequence(Integer integer) {
_outputEntrySequence = integer;
}
/**
* returns the endDate
*
* @return the code
*
* @hibernate.property column="END_DATE"
*/
public Date getEndDate() {
return _endDate;
}
/**
* @param endDate The endDate to set.
*/
public void setEndDate(Date endDate) {
_endDate = endDate;
}
/**
* @return the enseigne pays
* @hibernate.many-to-one
* column="C_PY"
* not-null="true"
*/
public EnseignePays getCPy() {
return _cPy;
}
/**
* @param cpy the enseigne pays to set
*/
public void setCPy(EnseignePays cPy) {
_cPy = cPy;
}
/**
* set the property value
*
* @param b value
*/
public void setHardCoded(boolean b) {
_hardCoded = b;
}
/**
* return the property value
*
* @return value
*
* @hibernate.property column="HARD_CODED" type="yes_no"
*/
public boolean isHardCoded() {
return _hardCoded;
}
}
mon problème vient certainement du mapping... en faite qd je créer ma rubric il ne crée pas de rubricTicketAdmin...
est ce que quelqu'un peut m'aider....
Partager