-->
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: Recommendations for mixing hbm and annotations?
PostPosted: Fri Jan 20, 2006 3:21 pm 
Newbie

Joined: Sat Jan 07, 2006 10:33 am
Posts: 18
Location: New York NY
After some confusion, I recently discovered that the current release of Hibernate Annotations (3.1b7) does not support maps.

I only recently started with Hibernate, so I started using Hibernate Annotations right away. The appeal was obvious -- I guess it wasn't obvious that certain essential things weren't implemented yet, but this is to be expected from the big "beta" label. :-)

So I annotated all of the classes I want to persist, and now that I've found out about missing map support, I am left with the question of what to do. Although the documentation says that hbm files and annotations can be "mixed and matched", it is apparently not possible to use both an hbm file and annotations together to set up persistence for a particular class.

I have classes with, let's say, 20 properties that I want to persist. 1 or 2 in any case may be a map. Do I have any other option, other than to create an entire hbm file for the class, leaving the annotations in that class unused? Is there some secret/special/experimental way that I might be able to just define the <map> stuff in an hbm file, and still use the rest of the annotations that are already there?

I know it's a long shot, just wondering. Thanks for such a fantastic product.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 6:11 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This is planned ANN-1
but Map are not really something useful from a elational POV. You probably can workaround and avoid using it.

You cannot use hbm and annotation on the same hierarchy (hence on the same class).

Patch welcome, BTW :-)

_________________
Emmanuel


Top
 Profile  
 
 Post subject: had been trying to work around maps...
PostPosted: Fri Jan 20, 2006 9:18 pm 
Newbie

Joined: Sat Jan 07, 2006 10:33 am
Posts: 18
Location: New York NY
emmanuel wrote:
but Map are not really something useful from a elational POV. You probably can workaround and avoid using it.

Actually, I had been trying to deal with maps using something like this example:

Code:
@Entity(access = AccessType.FIELD)
@Inheritance(
    strategy=InheritanceType.SINGLE_TABLE,
    discriminatorType=DiscriminatorType.STRING
)
public class TestBundle
{
    @ManyToMany(cascade = CascadeType.ALL)
    @MapKey
    @Column(name = "`testCases`")
    private Map<String, TestCase> testCases = new HashMap<String, TestCase>();
    ...
}

But no matter what I did, some of the SQL generated would always contain a "formula" referring to a column that didn't exist. As far as I understood, this was supposed to be used as a discriminator. (I originally did not have the @Inheritance annotation at the top, but adding it did not seem to change whether this "formula" got created.) I don't see the need for a discriminator in my case, though maybe I misunderstand something -- in any case, I could not make this formula go away, and so my load operations were always failing because of requests for this column.

When I searched for errors similar to mine (on the Hibernate site including forum, in JIRA, on the web in general), I didn't find someone in exactly the same situation, but did find several admonitions that map support wasn't implemented yet.

But maybe I was closer to the right incantation than I thought? That would be great. I don't really want to have to use the hbm files at all....


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.