[
http://opensource.atlassian.com/projects/hibernate/browse/ANN-252?page=co...
]
Michael Bergens commented on ANN-252:
-------------------------------------
This issue is marked as fixed as of 3.3.0.GA but I still see this problem with 3.3.0.GA;
to make things worse: with the wrong Entity the annotations config still fails silently,
all I see as the result is the empty schema, both in the export .sql and in the database.
There is surely a workaround of setting up the imports straight, but it adds quite a bit
to the learning curve and creates confusion.
It's no good that the javax.persistence annotations are named the same as the
org.hibernate.annotation.*. Wonder whose fault is that, which was the first - the Sun or
Hibernate to come up with these names?
With this name confusion, it seems like a good practice to always use full package specs
like this:
@javax.persistence.Table(name = ..., uniqueConstraints = ...)
@org.hibernate.annotations.Table(appliesTo = ..., comment = ...)
public class ... {
...
Should this be highlighted in the documentation so new people don't waste time lost
between these two packages?
AnnotationConfiguration silently ignores classes that are annotated
with wrong Entity, or not annotated.
--------------------------------------------------------------------------------------------------------
Key: ANN-252
URL:
http://opensource.atlassian.com/projects/hibernate/browse/ANN-252
Project: Hibernate Annotations
Issue Type: Improvement
Components: binder
Affects Versions: 3.1beta8
Reporter: Damon Feldman
Assignee: Emmanuel Bernard
Fix For: 3.3.0.ga
Original Estimate: 1 hour
Remaining Estimate: 1 hour
If you import the wrong Entity (e.g. org.hibernate.annotation.Entity) in a persistent
class, the class is ignored, but no logging or other notification is made of the issue.
Recommend: adding a log statement:
log.warn("The class" + annotatedClass.getName() +"does not have the proper
annotation: " + Entity.class.getName());
Here is the code that seems responsible:
/**
* Read a mapping from the class annotation metadata (JSR 175).
*
* @param persistentClass the mapped class
* @return the configuration object
*/
public AnnotationConfiguration addAnnotatedClass(Class persistentClass) throws
MappingException {
try {
if ( persistentClass.isAnnotationPresent( Entity.class ) ) {
annotatedClassEntities.put( persistentClass.getName(), persistentClass );
}
annotatedClasses.add( persistentClass );
return this;
}
catch (MappingException me) {
log.error( "Could not compile the mapping annotations", me );
throw me;
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira