-->
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.  [ 6 posts ] 
Author Message
 Post subject: DefaultComponentSafeNamingStrategy not working
PostPosted: Wed Jan 11, 2006 11:39 am 
Regular
Regular

Joined: Thu Oct 13, 2005 4:19 am
Posts: 98
Hi,

I am using Hibernate 3.1 with hibernate-annotations 3.1b7 (through a spring hibernate3 configuration without the entity manager).

The following code won't run:

Code:
@Entity
public class Person {

  private Dog firstDog;
  private Dog secondDog;

  // getters & setters for the firstDog and SecondDog
}

@Embeddable
public class Dog {
 
  private String dogName;

  // getters & setters for dogName
}


It gives me an exception :
Repeated column in mapping for entity: x.y.Person column: dogName

Yet I am using DefaultComponentSafeNamingStrategy, which according to the documentation should solve this problem:

"If you want to have the same embeddeable object type twice in the same entity, the column name defaulting will not work: at least one of the columns will have to be explicit. Hibernate goes beyond the EJB3 spec and allows you to enhance the defaulting mechanism through the NamingStrategy. DefaultComponentSafeNamingStrategy is a small improvement of the default EJB3NamingStrategy that allows embedded objects to be defaulted even if used twice in the same entity."

_________________
http://www.ohloh.net/accounts/ge0ffrey


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 11:56 am 
Regular
Regular

Joined: Thu Oct 13, 2005 4:19 am
Posts: 98
I did some more tests, just found out that the above code will work,
but my code didn't because I used a @ManyToOne attribute in my Dog...

This is described in the documentation that it cannot be used in an Embeddable, which is a pity, because I kinda need it there :)

_________________
http://www.ohloh.net/accounts/ge0ffrey


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 6:50 am 
Regular
Regular

Joined: Thu Oct 13, 2005 4:19 am
Posts: 98
Now beta 8 I have not problems: ManyToOne does work in Embeddable

_________________
http://www.ohloh.net/accounts/ge0ffrey


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 2:47 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
right, I made some changes that "fixed" the issue. This is still not officially supported since I don't have any unit test on it, but I'm currintly writing some

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 5:45 am 
Regular
Regular

Joined: Thu Oct 13, 2005 4:19 am
Posts: 98
FYI

Since beta 8 I have no problems with:

An @Embeddable with a @ManyToOne(fetch = FetchType.EAGER) in an @Embeddable in a @Entity.

This feature makes for a very clean design, thanks :) Especially combined with the smart naming of embedded properties.
So the docs are currently wrong (it does work), but I hope it becomes a supported/documented/unitTested feature.

_________________
http://www.ohloh.net/accounts/ge0ffrey


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 29, 2009 11:20 pm 
Newbie

Joined: Fri Feb 08, 2008 2:41 pm
Posts: 18
How did you configure the namingStrategy? I am using Hibernate Annotations 3.4 and Spring 2.5 but am still getting a "Repeated column in mapping" error.

Code:
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
.......
        <property name="namingStrategy">
            <bean class="org.hibernate.cfg.DefaultComponentSafeNamingStrategy" />
        </property>
</bean>


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