hibernate - Mapping association with Composite-id -
i'm new on hibernate, i've doubt how can represent case:
-->table message: - (pk) msgsender -> foreign key table 'user' - (pk) msgdestination -> foreign key table 'user' - (pk) msgdatesend - msgcontent - isreaded
-->table user -(pk) username - ...
this message.hbm:
<?xml version="1.0"?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 3.0//en" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="message" table="message"> <composite-id name="id" class="messageid"> <key-many-to-one name="msgsender" class="user"> <column name="msgsender"/> </key-many-to-one> <key-many-to-one name="msgdestination" class="user"> <column name="msgdestination"/> </key-many-to-one> <key-property name="msgdatesend" type="double" column="msgdatesend"/> </composite-id> <property name="msgcontent" type="java.lang.string"> <column name="msgcontent" /> </property> <property name="isreaded" type="boolean" access="field"> <column name="isreaded" /> </property> </class> </hibernate-mapping>
and pojo's: class message:
public class message implements serializable { /** * */ private static final long serialversionuid = -5319468638732762052l; private messageid id; private string msgcontent; private boolean isreaded; public message() { this.id = new msgcontentid(); } /** * @return id */ public messageid getid() { return id; } /** * @param id id set */ public void setmessageid(messageid mid) { this.id = mid; } /** * @return msgcontent */ public string getmsgcontent() { return msgcontent; } /** * @param msgcontent * msgcontent set */ public void setmsgcontent(string msgcontent) { this.msgcontent = msgcontent; } /** * @return isreaded */ public boolean getisreaded() { return isreaded; } /** * @param isreaded * isreaded set */ public void setisreaded(boolean isreaded) { this.isreaded = isreaded; } }
class messageid:
public class messageid implements serializable{ /** * */ private static final long serialversionuid = 1l; user msgsender; user msgdestination; double msgsend; /** * @return msgsender */ public user getmsgsender() { return msgsender; } /** * @param msgsender * msgsender set */ public void setmsgsender(user msgsender) { this.msgsender = msgsender; } /** * @return msgdestination */ public user getmsgdestination() { return msgdestination; } /** * @param msgdestination * msgdestination set */ public void setmsgdestination(user msgdestination) { this.msgdestination = msgdestination; } /** * @return msgsend */ public double getmsgsend() { return msgsend; } /** * @param msgsend * msgsend set */ public void setmsgsend(double msgsend) { this.msgsend = msgsend; } }
with structure hibernate makes no insert, delete, ... me solve problem?
thanks in advance.
Comments
Post a Comment