[
https://hibernate.onjira.com/browse/METAGEN-85?page=com.atlassian.jira.pl...
]
Hardy Ferentschik updated METAGEN-85:
-------------------------------------
Description:
This bug is related to this thread of the mailing list:
http://lists.jboss.org/pipermail/hibernate-dev/2012-March/007894.html
From my original post:
{quote}
While working on Hibernate JPA Modelgen, I noticed that there are test
failures in _MixedConfigurationTest_. I thought it was because of my
own changes but I also have this problem with a fresh git clone from
the official repo:
{quote}
{noformat}
Running org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest
Tests run: 4, Failures: 4, Errors: 0, Skipped: 0, Time elapsed: 2.494
sec <<< FAILURE!
Results :
Failed tests:
testAccessTypeForXmlConfiguredEmbeddables(org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest):
org.hibernate.jpamodelgen.test.mixedmode.Coordinates_ was not
generated.
testDefaultAccessTypeApplied(org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest):
org.hibernate.jpamodelgen.test.mixedmode.Vehicle_ was not generated.
testExplicitXmlConfiguredAccessTypeApplied(org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest):
org.hibernate.jpamodelgen.test.mixedmode.Vehicle_ was not generated.
testMixedConfiguration(org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest):
org.hibernate.jpamodelgen.test.mixedmode.RentalCar_ was not generated.
Tests run: 4, Failures: 4, Errors: 0, Skipped: 0
{noformat}
From what I can see, there is at least a problem with
_AnnotationMetaEntity.mergeInMembers_: the merged in members aren't
really affected to the new entity as the hostingEntity of the
attribute is still the original entity.
In the case of the _ZeroCoordinates_ entity, it leads to a compilation
error as the _SingularAttribute_ import isn't added to the right context
(it's added to the original _XmlMetaEmbeddable_ context instead of the
_AnnotationEmbeddable_ context this attribute is attached to at the end
of the annotation processing). The content of the generated class is
as follows:
{code}
package org.hibernate.jpamodelgen.test.mixedmode;
import javax.annotation.Generated;
import javax.persistence.metamodel.StaticMetamodel;
@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
@StaticMetamodel(ZeroCoordinates.class)
public abstract class ZeroCoordinates_ {
public static volatile SingularAttribute<ZeroCoordinates,
Float> longitude;
public static volatile SingularAttribute<ZeroCoordinates,
Float> latitude;
}
{code}
I was wondering if providing the way to overwrite the hostingEntity
(via removing the final and adding a setter) would be acceptable or
not?
Even if I do so (draft patch attached), I still have a test failing
claiming that _ZeroCoordinates_ shouldn't have any attributes generated.
IMHO, there are 2 problems here:
* we need to decide if having the attributes generated for _ZeroCoordinates_ is the wanted
behavior. Considering that they are explicitly declared in the XML mapping, I think so
but, as there is an explicit test checking that they aren't, I'm not sure it's
the expected behavior;
* if we fix the above problem by removing the attributes from _ZeroCoordinates_, we need
to write a test to show the problem of _AnnotationMetaEntity.mergeInMembers_ and fix it
(either with the patch provided or with another one doing the same thing).
Depending on what we decide, I can probably prepare a pull request for this problem if you
want it.
Guillaume
was:
This bug is related to this thread of the mailing list:
http://lists.jboss.org/pipermail/hibernate-dev/2012-March/007894.html
From my original post:
********
While working on Hibernate JPA Modelgen, I noticed that there are test
failures in MixedConfigurationTest . I thought it was because of my
own changes but I also have this problem with a fresh git clone from
the official repo:
Running org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest
Tests run: 4, Failures: 4, Errors: 0, Skipped: 0, Time elapsed: 2.494
sec <<< FAILURE!
Results :
Failed tests:
testAccessTypeForXmlConfiguredEmbeddables(org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest):
org.hibernate.jpamodelgen.test.mixedmode.Coordinates_ was not
generated.
testDefaultAccessTypeApplied(org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest):
org.hibernate.jpamodelgen.test.mixedmode.Vehicle_ was not generated.
testExplicitXmlConfiguredAccessTypeApplied(org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest):
org.hibernate.jpamodelgen.test.mixedmode.Vehicle_ was not generated.
testMixedConfiguration(org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest):
org.hibernate.jpamodelgen.test.mixedmode.RentalCar_ was not generated.
Tests run: 4, Failures: 4, Errors: 0, Skipped: 0
From what I can see, there is at least a problem with
AnnotationMetaEntity.mergeInMembers: the merged in members aren't
really affected to the new entity as the hostingEntity of the
attribute is still the original entity.
In the case of the ZeroCoordinates entity, it leads to a compilation
error as the SingularAttribute import isn't added to the right context
(it's added to the original XmlMetaEmbeddable context instead of the
AnnotationEmbeddable context this attribute is attached to at the end
of the annotation processing). The content of the generated class is
as follows:
package org.hibernate.jpamodelgen.test.mixedmode;
import javax.annotation.Generated;
import javax.persistence.metamodel.StaticMetamodel;
@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
@StaticMetamodel(ZeroCoordinates.class)
public abstract class ZeroCoordinates_ {
public static volatile SingularAttribute<ZeroCoordinates,
Float> longitude;
public static volatile SingularAttribute<ZeroCoordinates,
Float> latitude;
}
I was wondering if providing the way to overwrite the hostingEntity
(via removing the final and adding a setter) would be acceptable or
not?
********
Even if I do so (draft patch attached), I still have a test failing
claiming that ZeroCoordinates shouldn't have any attributes generated.
IMHO, there are 2 problems here:
- we need to decide if having the attributes generated for ZeroCoordinates is the wanted
behaviour. Considering that they are explicitely declared in the XML mapping, I think so
but, as there is an explicit test checking that they aren't, I'm not sure it's
the expected behaviour;
- if we fix the above problem by removing the attributes from ZeroCoordinates, we need to
write a test to show the problem of AnnotationMetaEntity.mergeInMembers and fix it (either
with the patch provided or with another one doing the same thing).
Depending on what we decide, I can probably prepare a pull request for this problem if you
want it.
--
Guillaume
MixedConfigurationTest failing
------------------------------
Key: METAGEN-85
URL:
https://hibernate.onjira.com/browse/METAGEN-85
Project: Hibernate Metamodel Generator
Issue Type: Bug
Components: processor
Affects Versions: 1.2.0.Final
Reporter: Guillaume Smet
Assignee: Hardy Ferentschik
Attachments: attach-attributes-to-the-right-entity.diff
This bug is related to this thread of the mailing list:
http://lists.jboss.org/pipermail/hibernate-dev/2012-March/007894.html
From my original post:
{quote}
While working on Hibernate JPA Modelgen, I noticed that there are test
failures in _MixedConfigurationTest_. I thought it was because of my
own changes but I also have this problem with a fresh git clone from
the official repo:
{quote}
{noformat}
Running org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest
Tests run: 4, Failures: 4, Errors: 0, Skipped: 0, Time elapsed: 2.494
sec <<< FAILURE!
Results :
Failed tests:
testAccessTypeForXmlConfiguredEmbeddables(org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest):
org.hibernate.jpamodelgen.test.mixedmode.Coordinates_ was not
generated.
testDefaultAccessTypeApplied(org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest):
org.hibernate.jpamodelgen.test.mixedmode.Vehicle_ was not generated.
testExplicitXmlConfiguredAccessTypeApplied(org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest):
org.hibernate.jpamodelgen.test.mixedmode.Vehicle_ was not generated.
testMixedConfiguration(org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest):
org.hibernate.jpamodelgen.test.mixedmode.RentalCar_ was not generated.
Tests run: 4, Failures: 4, Errors: 0, Skipped: 0
{noformat}
From what I can see, there is at least a problem with
_AnnotationMetaEntity.mergeInMembers_: the merged in members aren't
really affected to the new entity as the hostingEntity of the
attribute is still the original entity.
In the case of the _ZeroCoordinates_ entity, it leads to a compilation
error as the _SingularAttribute_ import isn't added to the right context
(it's added to the original _XmlMetaEmbeddable_ context instead of the
_AnnotationEmbeddable_ context this attribute is attached to at the end
of the annotation processing). The content of the generated class is
as follows:
{code}
package org.hibernate.jpamodelgen.test.mixedmode;
import javax.annotation.Generated;
import javax.persistence.metamodel.StaticMetamodel;
@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
@StaticMetamodel(ZeroCoordinates.class)
public abstract class ZeroCoordinates_ {
public static volatile SingularAttribute<ZeroCoordinates,
Float> longitude;
public static volatile SingularAttribute<ZeroCoordinates,
Float> latitude;
}
{code}
I was wondering if providing the way to overwrite the hostingEntity
(via removing the final and adding a setter) would be acceptable or
not?
Even if I do so (draft patch attached), I still have a test failing
claiming that _ZeroCoordinates_ shouldn't have any attributes generated.
IMHO, there are 2 problems here:
* we need to decide if having the attributes generated for _ZeroCoordinates_ is the
wanted behavior. Considering that they are explicitly declared in the XML mapping, I think
so but, as there is an explicit test checking that they aren't, I'm not sure
it's the expected behavior;
* if we fix the above problem by removing the attributes from _ZeroCoordinates_, we need
to write a test to show the problem of _AnnotationMetaEntity.mergeInMembers_ and fix it
(either with the patch provided or with another one doing the same thing).
Depending on what we decide, I can probably prepare a pull request for this problem if
you want it.
Guillaume
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira