You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "jevardat (JIRA)" <ji...@apache.org> on 2015/04/29 11:15:05 UTC

[jira] [Updated] (OPENJPA-2579) HandlerFieldStrategy installed on abstract class

     [ https://issues.apache.org/jira/browse/OPENJPA-2579?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

jevardat updated OPENJPA-2579:
------------------------------
    Description: 
Hello OpenJPA community

I submit this issue, because I ran into a rather weird behavior while using @Strategy on an abstract Entity having two subclasses that map to the actual tables.
I encounter the problem on both 2.3.0 and 2.4.0 version of openjpa.

The problem is that I received the exception
{code}
...
Caused by: <openjpa-2.4.0-r422266:1674604 fatal user error> org.apache.openjpa.persistence.ArgumentException: Attempt to map "gaia.cu7.om.input.TimeSeries.fObsTimes" failed: the owning entity is not mapped.
	at org.apache.openjpa.jdbc.meta.MappingInfo.assertTable(MappingInfo.java:628)
	at org.apache.openjpa.jdbc.meta.MappingInfo.createColumns(MappingInfo.java:558)
	at org.apache.openjpa.jdbc.meta.ValueMappingInfo.getColumns(ValueMappingInfo.java:178)
	at org.apache.openjpa.jdbc.meta.strats.HandlerStrategies.map(HandlerStrategies.java:65)
	at org.apache.openjpa.jdbc.meta.strats.HandlerFieldStrategy.map(HandlerFieldStrategy.java:82)
	at org.apache.openjpa.jdbc.meta.FieldMapping.setStrategy(FieldMapping.java:148)
	at org.apache.openjpa.jdbc.meta.RuntimeStrategyInstaller.installStrategy(RuntimeStrategyInstaller.java:81)
	at org.apache.openjpa.jdbc.meta.FieldMapping.resolveMapping(FieldMapping.java:498)
	at org.apache.openjpa.jdbc.meta.FieldMapping.resolve(FieldMapping.java:463)
	at org.apache.openjpa.jdbc.meta.ClassMapping.resolveNonRelationMappings(ClassMapping.java:895)
	at org.apache.openjpa.jdbc.meta.MappingRepository.prepareMapping(MappingRepository.java:416)
	at org.apache.openjpa.meta.MetaDataRepository.preMapping(MetaDataRepository.java:769)
	at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:658)
	... 38 more
{code}


I'am not sure of the root cause of the problem but after debugging, I found that in the RunTimeStrategyInstaller, in the installStrategy method a handlerField strategy is installed even is the class is abstract. 

{code}
public void installStrategy(FieldMapping field) {
        FieldStrategy strategy = null;
        ClassMapping owner = getOutermostDefiningMapping(field); 
        if (owner != null && !owner.isEmbeddable() && !owner.isAbstract())
            strategy = repos.namedStrategy(field, true);
...
{code}

And this strategy is installed because owner.isAbstract() is false, which I don't understand since the class is abstract and not mapped to any table. In my case only subclasses are mapped, I use TABLE_PER_CLASS strategy.

Obviously, when I do not use any strategy, the installed strategy is NoneFieldStrategy, but the ownser.isAbstract() is still false.

So Maybe the problem is elsewhere. Here is my mapping:
{code}
@Entity
@IdClass(TimeSeries.TimeSeriesId.class)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Access(AccessType.FIELD)
@Immutable
public abstract class TimeSeries .... extends other abstract class not jpa mapped


@NotNull(message = "Observation times cannot be empty or null.")
@PersistentCollection(fetch = FetchType.EAGER)
@Strategy("gaia.cu7.om.dal.dictionary.PostgresArrayHandler2")
@Column(name = "obstimes", updatable = false)
protected double[] fObsTimes;
{code}


Thanks for any help
Gregory




  was:
Hello OpenJPA community

I submit this issue, because I ran into a rather weird behavior while using @Strategy on an abstract Entity having two subclasses that map to the actual tables.
I encounter the problem on both 2.3.0 and 2.4.0 version of openjpa.

The problem is that I received the exception
{code}
...
Caused by: <openjpa-2.4.0-r422266:1674604 fatal user error> org.apache.openjpa.persistence.ArgumentException: Attempt to map "gaia.cu7.om.input.TimeSeries.fObsTimes" failed: the owning entity is not mapped.
	at org.apache.openjpa.jdbc.meta.MappingInfo.assertTable(MappingInfo.java:628)
	at org.apache.openjpa.jdbc.meta.MappingInfo.createColumns(MappingInfo.java:558)
	at org.apache.openjpa.jdbc.meta.ValueMappingInfo.getColumns(ValueMappingInfo.java:178)
	at org.apache.openjpa.jdbc.meta.strats.HandlerStrategies.map(HandlerStrategies.java:65)
	at org.apache.openjpa.jdbc.meta.strats.HandlerFieldStrategy.map(HandlerFieldStrategy.java:82)
	at org.apache.openjpa.jdbc.meta.FieldMapping.setStrategy(FieldMapping.java:148)
	at org.apache.openjpa.jdbc.meta.RuntimeStrategyInstaller.installStrategy(RuntimeStrategyInstaller.java:81)
	at org.apache.openjpa.jdbc.meta.FieldMapping.resolveMapping(FieldMapping.java:498)
	at org.apache.openjpa.jdbc.meta.FieldMapping.resolve(FieldMapping.java:463)
	at org.apache.openjpa.jdbc.meta.ClassMapping.resolveNonRelationMappings(ClassMapping.java:895)
	at org.apache.openjpa.jdbc.meta.MappingRepository.prepareMapping(MappingRepository.java:416)
	at org.apache.openjpa.meta.MetaDataRepository.preMapping(MetaDataRepository.java:769)
	at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:658)
	... 38 more
{code}


I'am not sure of the root cause of the problem but after debugging, I found that in the RunTimeStrategyInstaller, in the installStrategy method a handlerField strategy is installed even is the class is abstract. 

{code}
public void installStrategy(FieldMapping field) {
        FieldStrategy strategy = null;
        ClassMapping owner = getOutermostDefiningMapping(field); 
        if (owner != null && !owner.isEmbeddable() && !owner.isAbstract())
            strategy = repos.namedStrategy(field, true);
...
{code}

And this strategy is installed because owner.isAbstract() is false, which I don't understand since the class is abstract and not mapped to any table. In my case only subclasses are mapped, I use TABLE_PER_CLASS strategy.

Obviously, when I do not use any strategy, the installed strategy is NoneFieldStrategy, but the ownser.isAbstract() is still false.

So Maybe the problem is elsewhere. Here is my mapping:
{code}
@Entity
@IdClass(TimeSeries.TimeSeriesId.class)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Access(AccessType.FIELD)
@Immutable
public abstract class TimeSeries .... extends other abstract class not jpa mapped


@NotNull(message = "Observation times cannot be empty or null.")
@PersistentCollection(fetch = FetchType.EAGER)
@Strategy("gaia.cu7.om.dal.dictionary.PostgresArrayHandler2")
@Column(name = "obstimes", updatable = false)
protected double[] fObsTimes;
{code}






> HandlerFieldStrategy installed on abstract class
> ------------------------------------------------
>
>                 Key: OPENJPA-2579
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2579
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc, jpa, kernel
>    Affects Versions: 2.3.0, 2.4.0
>            Reporter: jevardat
>
> Hello OpenJPA community
> I submit this issue, because I ran into a rather weird behavior while using @Strategy on an abstract Entity having two subclasses that map to the actual tables.
> I encounter the problem on both 2.3.0 and 2.4.0 version of openjpa.
> The problem is that I received the exception
> {code}
> ...
> Caused by: <openjpa-2.4.0-r422266:1674604 fatal user error> org.apache.openjpa.persistence.ArgumentException: Attempt to map "gaia.cu7.om.input.TimeSeries.fObsTimes" failed: the owning entity is not mapped.
> 	at org.apache.openjpa.jdbc.meta.MappingInfo.assertTable(MappingInfo.java:628)
> 	at org.apache.openjpa.jdbc.meta.MappingInfo.createColumns(MappingInfo.java:558)
> 	at org.apache.openjpa.jdbc.meta.ValueMappingInfo.getColumns(ValueMappingInfo.java:178)
> 	at org.apache.openjpa.jdbc.meta.strats.HandlerStrategies.map(HandlerStrategies.java:65)
> 	at org.apache.openjpa.jdbc.meta.strats.HandlerFieldStrategy.map(HandlerFieldStrategy.java:82)
> 	at org.apache.openjpa.jdbc.meta.FieldMapping.setStrategy(FieldMapping.java:148)
> 	at org.apache.openjpa.jdbc.meta.RuntimeStrategyInstaller.installStrategy(RuntimeStrategyInstaller.java:81)
> 	at org.apache.openjpa.jdbc.meta.FieldMapping.resolveMapping(FieldMapping.java:498)
> 	at org.apache.openjpa.jdbc.meta.FieldMapping.resolve(FieldMapping.java:463)
> 	at org.apache.openjpa.jdbc.meta.ClassMapping.resolveNonRelationMappings(ClassMapping.java:895)
> 	at org.apache.openjpa.jdbc.meta.MappingRepository.prepareMapping(MappingRepository.java:416)
> 	at org.apache.openjpa.meta.MetaDataRepository.preMapping(MetaDataRepository.java:769)
> 	at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:658)
> 	... 38 more
> {code}
> I'am not sure of the root cause of the problem but after debugging, I found that in the RunTimeStrategyInstaller, in the installStrategy method a handlerField strategy is installed even is the class is abstract. 
> {code}
> public void installStrategy(FieldMapping field) {
>         FieldStrategy strategy = null;
>         ClassMapping owner = getOutermostDefiningMapping(field); 
>         if (owner != null && !owner.isEmbeddable() && !owner.isAbstract())
>             strategy = repos.namedStrategy(field, true);
> ...
> {code}
> And this strategy is installed because owner.isAbstract() is false, which I don't understand since the class is abstract and not mapped to any table. In my case only subclasses are mapped, I use TABLE_PER_CLASS strategy.
> Obviously, when I do not use any strategy, the installed strategy is NoneFieldStrategy, but the ownser.isAbstract() is still false.
> So Maybe the problem is elsewhere. Here is my mapping:
> {code}
> @Entity
> @IdClass(TimeSeries.TimeSeriesId.class)
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> @Access(AccessType.FIELD)
> @Immutable
> public abstract class TimeSeries .... extends other abstract class not jpa mapped
> @NotNull(message = "Observation times cannot be empty or null.")
> @PersistentCollection(fetch = FetchType.EAGER)
> @Strategy("gaia.cu7.om.dal.dictionary.PostgresArrayHandler2")
> @Column(name = "obstimes", updatable = false)
> protected double[] fObsTimes;
> {code}
> Thanks for any help
> Gregory



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)