Hello,
I have some entity bean called Message has four properties: code , titles , bodies and message Type. the message contain one code like "MSG001" and one type"ERR" and multiple titles every title for human language and multiple bodies .
to initiate the message I do like following:
Quote:
Message message1=new Message();
message1.setCode("MSG001");
message1.setMessageType(new MessageType(MessageType.Type.MSG));
message1.getTitles().put("en", "Bill Payment");
message1.getTitles().put("ar", "دفع الفاتورة");
message1.getTitles().put("fr", "Paiement des factures");
message1.getBodies().put("en", "Bill Payment\nBill Payment\nBill Payment\n");
message1.getBodies().put("ar", "دفع الفاتورة\nدفع الفاتورة\nدفع الفاتورة\n");
message1.getBodies().put("fr", "Paiement des factures\nPaiement des factures\nPaiement des factures\n");
the message declaration like the following and for sure has getter and setter for each property
public class
Message implements Cloneable ,Serializable{
private String code;
private Hashtable<String, String> titles;
private Hashtable<String, String> bodies;
private MessageType messageType;
}
and MessageType class like the following:
public class MessageType implements Serializable{
private Type type;
public String getCode()
{
return this.type.name();
}
public MessageType(Type type)
{
this.type = type;
}
public enum Type {
MSG("message"), WAR("warring"), ERR("error"), QUE("question");
private String label;
public String getLabel()
{
return label;
}
Type(String l)
{
label = l;
}
}
}
now I dont know how to design the database tables and put annotations for this relation kindly help me.
I tried to make the following DB design but I don't know how to annotate it:
CREATE TABLE `message` (
`idmessage` int(11) NOT NULL DEFAULT '0',
`code` varchar(6) NOT NULL,
`type` varchar(3) NOT NULL,
PRIMARY KEY (`idmessage`),
UNIQUE KEY `code_UNIQUE` (`code`)
)
CREATE TABLE `title` (
`idtitle` int(11) NOT NULL AUTO_INCREMENT,
`idMessage` int(11) DEFAULT NULL,
`language` varchar(2) NOT NULL,
`content` varchar(50) NOT NULL,
PRIMARY KEY (`idtitle`),
KEY `idmessage` (`idMessage`),
CONSTRAINT `idmessage` FOREIGN KEY (`idMessage`) REFERENCES `message` (`idmessage`) ON DELETE CASCADE ON UPDATE CASCADE)
CREATE TABLE `body` (
`idbody` int(11) NOT NULL AUTO_INCREMENT,
`idmassage` int(11) DEFAULT NULL,
`language` varchar(2) NOT NULL,
`content` varchar(300) NOT NULL,
PRIMARY KEY (`idbody`),
KEY `idmsg` (`idmassage`),
CONSTRAINT `idmsg` FOREIGN KEY (`idmassage`) REFERENCES `message` (`idmessage`) ON DELETE CASCADE ON UPDATE CASCADE)