-->
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.  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: NamingStrategy, EntityMangerFactory and persistence.xml
PostPosted: Tue Jul 12, 2005 1:08 am 
Beginner
Beginner

Joined: Tue Mar 15, 2005 2:36 am
Posts: 32
Location: Bonn, Germany
Hello!

This is (in standard and programmatic Hibernate), what I need:
Code:
AnnotationConfiguration cfg = new AnnotationConfiguration();
cfg.setNamingStrategy(new MyStrategy());


But when using the Persistence API from EJB3, I don't see the cfg object. So, I like to pass the name of my strategy class as a property in /META-INF/persistence.xml ... but I can't find the string constant pointing to a strategy class name. At least the Environment class doesn't provide one, does it?

Something like:
Code:
...
    <property name="hibernate.naming.strategy" value="MyStrategy" />
  </properties>
</entity-manager>



Or do I have to roll my own service provider? Nah... then I'll file a feature request against HibernatePersistence - it should provide a protected method like customize(AnnotatedConfiguration cfg) which can be overriden by subclasses. Line 368 in revision 1.25 is a good insertion point. Just before the fixed EJB3 properties are set the session factory is created... :)

Cheers,
Christian


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 12:40 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Open a JIRA request

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 3:56 pm 
Beginner
Beginner

Joined: Tue Mar 15, 2005 2:36 am
Posts: 32
Location: Bonn, Germany
http://opensource.atlassian.com/projects/hibernate/browse/EJB-35

Done.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 6:14 am 
Beginner
Beginner

Joined: Tue Mar 15, 2005 2:36 am
Posts: 32
Location: Bonn, Germany
Sormuras wrote:


Hoped to see this issue solved in Hibernate EntityManager Changelog from 3.1beta3 (14-09-2005) ... maybe beta4? :)

Cheers,
Christian


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 3:22 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I do have some conceptual issues that prevented me to close it.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 5:30 pm 
Beginner
Beginner

Joined: Mon Mar 28, 2005 12:58 pm
Posts: 27
Emmanuel,

Has there been any decisions made about this naming stratgey issue? I'm upgrading our product to start using entityManager beta 3 (w/ annotations beta 5) to be EJB3.0 compliant but none of the EJBQLs will work because of the mismatches in all the column names (we have our own NamingStrategy implementation).

Ejb3Configuration class also doesn't allow me to get to the AnnotationConfiguration instance so there is no way for me to do a temporary change for now. Are there any temporary workaround solutions that I can use ?

Thanks!
Aye


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 4:29 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
No sorry.
It's pretty trivial to add a setNAmingStrategy() to the Ejb3Configuration and delegate the call to the underlying annotationconfiguration.
But until I've solve the conceptual issues, I'll not add it to the release.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 02, 2005 12:22 pm 
Newbie

Joined: Thu Feb 12, 2004 6:19 pm
Posts: 10
I would happily live with the constraint that columnName(propertyToCoreColumnName()) == propertyToColumnName() if it meant I could use propertyToColumnName() with my Hibernate Annotations beans.

All the columnName() and tableName() implementations I've written just return their inputs anyway, so that constraint is already always true for me; my feeling is if you're going to bother specifying a table or column name explicitly in an annotation or a mapping document, you may as well specify the actual name from the database to make it clear to a reader what you mean. So the change favored by Emmanuel in the mailing list message would be zero loss to me. My hunch is that columnName() and tableName() are probably not that widely used, but I'm sure if I'm wrong I'll get plenty of replies telling me so.

The "no per-property annotations needed by default" feature of EJB3 is basically nonexistent for me at the moment -- I have to have @Column(name="xxx") on the majority of my properties because I can't define a naming strategy. In that respect Hibernate Annotations is a step backwards for me, since I make extensive use of naming strategies in Hibernate 3.0.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 02, 2005 12:46 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I'm currently working on the naming strategy support, but it's a real PITA. It actually requires the notion of logical naming and physical naming.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 04, 2005 7:07 pm 
Newbie

Joined: Thu Feb 12, 2004 6:19 pm
Posts: 10
I'm glad to hear it's being worked on. By the way, my "step backwards" comment was a bit harsh, so I apologize for that. Hibernate Annotations is an impressive piece of work -- the naming strategy problem is the only thing I've found wrong with it. Even with the @Column annotations it's a lot cleaner than all the XML files I used to have to maintain. It will be downright amazing once this problem is out of the way: for leaf-node classes, just one @Entity annotation at the top of the file and I'm done. You guys are doing a great job.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 6:46 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Check out Hibernate3 and Hibernate annotations from CVS, the naming strategy is implemented

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 7:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
did you or do you plan to add hibernate.naming_strategy support too ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 7:44 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
That's a different beast.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 7:47 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it was the original question ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 7:55 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Damn it! So I guess I'll have to support that ;-)

_________________
Emmanuel


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

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.