-->
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.  [ 3 posts ] 
Author Message
 Post subject: Map and UserTypes
PostPosted: Thu Oct 19, 2006 11:41 am 
Newbie

Joined: Mon Jan 12, 2004 5:46 pm
Posts: 8
Hi,
how should I map the following collection:

Code:
@CollectionOfElements
    @Type(type = "com.alcatel.rose.model.hibernate.ULDLValueIntegerType")
    @Columns(columns = {@Column(name = "ulcel"), @Column(name = "dlcel")})
    @Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
    @MapKeyManyToMany
    public Map<ChannelType, ULDLValueInteger> getCeElements()


ChannelType is annotated with @Entity and ULDLValueInteger is persisted using a hibernate UserType. When persisted, a ULDLValueInteger, it uses 2 columns in the database.

Code:
public class ULDLValueInteger {
    private Integer ul;
    private Integer dl;
.......
}


Using the above annotations I get an exception:

Code:
Caused by: org.hibernate.MappingException: collection index mapping has wrong number of columns: com.alcatel.rose.model.NodeBType.ceElements type: com.alcatel.rose.model.hibernate.ULDLValueIntegerType
   at org.hibernate.mapping.IndexedCollection.validate(IndexedCollection.java:69)
   at org.hibernate.cfg.Configuration.validate(Configuration.java:1030)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:688)


Any help is highly appreciated.


Top
 Profile  
 
 Post subject: hibernate-annotations-3.2.0.GA
PostPosted: Mon Oct 23, 2006 6:26 am 
Newbie

Joined: Mon Jan 12, 2004 5:46 pm
Posts: 8
It seems to work with the latest version of hibernate-annotations
hibernate-annotations-3.2.0.GA


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 21, 2007 6:16 am 
Newbie

Joined: Tue Aug 21, 2007 5:40 am
Posts: 1
Hi,
I'm having trouble trying to map my Map, i want the value of the map to use a UserType.

Code:
@CollectionOfElements
@JoinTable(name = "link_table", joinColumns = @JoinColumn(name = "id"))
@Type(type = "my.package.URLUserType")
@Column(name = "link_url")
@MapKey(columns = { @Column(name = "link_type") })
public Map<String, URL> getLinkMap() { ... }


The columns link_type and link_url are both VARCHAR2.

The above code causes both the key and value to be set as URL objects rather than just the value.
I need a way to specify that the value should use the URLUserType and the key should be a String.

I've tried this with both hibernate-annotations-3.2.0.GA and hibernate-annotations-3.3.0.GA.

Any help would be greatly appreciated.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.