-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mapping a primitive type on JoinTable ??
PostPosted: Fri Feb 19, 2010 5:21 am 
Newbie

Joined: Wed Jan 04, 2006 12:13 pm
Posts: 9
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.


Top
 Profile  
 
 Post subject: Re: Mapping a primitive type on JoinTable ??
PostPosted: Fri Feb 19, 2010 5:51 am 
Newbie

Joined: Wed Jan 04, 2006 12:13 pm
Posts: 9
Of course, I could create a T_Application entity, but for my T_SMS object is more simple to get a String representating the apllication name instead of an entity.


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

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.