-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Entity Relationships
PostPosted: Thu May 12, 2011 5:38 am 
Newbie

Joined: Thu May 12, 2011 5:16 am
Posts: 1
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
)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.