Hello,
I looked after a solution for a simple problem since 2 days, but without success.
My schema is the next :
Code:
CREATE TABLE `T_Application` (
`id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(20) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=InnoDB AUTO_INCREMENT=3 ;
CREATE TABLE `T_SMS` (
`id` int(10) unsigned NOT NULL auto_increment,
`clientCode` int(10) NOT NULL default '0',
`creationDate` datetime NOT NULL default '0000-00-00 00:00:00',
`content` varchar(160) default NULL,
`phone` varchar(12) NOT NULL,
`status` tinyint(4) NOT NULL default '0',
`ticketId` varchar(20) default NULL,
`statusDate` datetime default NULL,
`userName` varchar(20) NOT NULL default '',
`idApplication` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `idApplication` (`idApplication`)
) TYPE=InnoDB;
Thus, I would like to have an Entity like that :
Code:
@Entity
@Table(name = "T_SMS")
public class T_SMS implements Serializable {
private static final long serialVersionUID = 5498604302957327911L;
@ManyToOne(fetch = FetchType.EAGER, targetEntity = String.class)
@JoinColumn(name = "idApplication", table = "T_Application", unique = true, referencedColumnName = "id")
private String name;
@Id
@GeneratedValue
@Column(name = "id")
private Integer idSMS;
.................
I tried a @SecondaryTable, the @Enumerated, but these solutions was not suitable. However, we can use @CollectionOfElements to map a primitive list. So I think that it may be possible to do that.
Would you have a good solution ?
Thanks.