You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Krzysztof <ya...@gmail.com> on 2011/05/04 17:22:31 UTC

XMLValueHandler strategy not supported in Postgres?

Hello,
I'm trying to use XMLValueHandler strategy with Postgres 9 and openJPA 2.1.0
without success, although judging by the code other DBs might have similar
problems.

class Run {
...
    @Persistent(
    @Strategy ("org.apache.openjpa.jdbc.meta.strats.XMLValueHandler")    
	private RunConfiguration fConfiguration;
}

where RunConfiguration is properly annotated JAXB class.

This exception occurs even the generated 'Run' table has XML-type field
added and it happens during the named query that does not touch Run objects
that might reference XML field.


<Exception1>

<openjpa-2.1.0-r422266:1071316 fatal user error>
org.apache.openjpa.persistence.ArgumentException:
"gaia.cu7.om.Run.fConfiguration" declares a column that is not compatible
with the expected type "clob".  Column details:
Full Name: Run.fconfiguration
Type: unknown(2009)
Size: 2147483647
Default: null
Not Null: false

	at
org.apache.openjpa.jdbc.meta.MappingInfo.mergeColumn(MappingInfo.java:775)
	at
org.apache.openjpa.jdbc.meta.MappingInfo.createColumns(MappingInfo.java:593)
	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:146)
	at
org.apache.openjpa.jdbc.meta.RuntimeStrategyInstaller.installStrategy(RuntimeStrategyInstaller.java:82)
	at
org.apache.openjpa.jdbc.meta.FieldMapping.resolveMapping(FieldMapping.java:496)
	at org.apache.openjpa.jdbc.meta.FieldMapping.resolve(FieldMapping.java:461)
	at
org.apache.openjpa.jdbc.meta.ClassMapping.resolveNonRelationMappings(ClassMapping.java:895)
	at
org.apache.openjpa.jdbc.meta.MappingRepository.prepareMapping(MappingRepository.java:417)
	at
org.apache.openjpa.meta.MetaDataRepository.preMapping(MetaDataRepository.java:762)
	at
org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:651)
	at
org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:411)
	at
org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:384)
	at
org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:714)
	at
org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:643)
	at
org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:411)
	at
org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:384)
	at
org.apache.openjpa.meta.MetaDataRepository.resolveAll(MetaDataRepository.java:1954)
	at
org.apache.openjpa.meta.MetaDataRepository.getQueryMetaDataInternal(MetaDataRepository.java:1932)
	at
org.apache.openjpa.meta.MetaDataRepository.getQueryMetaData(MetaDataRepository.java:1919)
	at
org.apache.openjpa.persistence.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:1011)
	at
org.apache.openjpa.persistence.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:101)
	at gaia.cu7.om.dal.DbVariStore.getAllSources(DbVariStore.java:243)
	
</Exception1>

 
Debugging shows that in MappingInfo.java tmplate.type overrides proper XML
type of col::Column with clob, then causes exception from above.

<Exception2>
<MappingInfo.java:697>
      // use information from template column by default, allowing any
        // user-given specifics to override it
        int type = tmplate.getType();
        int size = tmplate.getSize();
        if (type == Types.OTHER) {
            int precis = 0;
            int scale = 0;
            if(given != null) {
                precis = given.getSize();
                scale = given.getDecimalDigits();
            }
            type =
                dict.getJDBCType(tmplate.getJavaType(), size == -1, precis,
                    scale, tmplate.isXML()); //<-------------- CLOB returned
(2005 instead of 2009 - SQLXML)
        }

I tried to create own XMLValueHandler that sets type to SQLXML on the map()
call, but this gives other errors during insert where insert statement
generated causes exception since it uses JavaTypes.STRING which is not
compatible with SQLXML of course..

<openjpa-2.1.0-r422266:1071316 fatal store error>
org.apache.openjpa.persistence.RollbackException: The transaction has been
rolled back.  See the nested exceptions for details on the errors that
occurred.
FailedObject: gaia.cu7.om.Run@799ac2e3
	at
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:585)
...
Caused by: <openjpa-2.1.0-r422266:1071316 fatal general error>
org.apache.openjpa.persistence.PersistenceException: The transaction has
been rolled back.  See the nested exceptions for details on the errors that
occurred.
FailedObject: gaia.cu7.om.Run@799ac2e3
	at
org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2316)
	at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2153)
	at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2051)
	at
org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1969)
	at
org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
	at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1493)
	at
org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:925)
	at
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:561)
	... 27 more
Caused by: <openjpa-2.1.0-r422266:1071316 fatal general error>
org.apache.openjpa.persistence.PersistenceException: ERROR: column
"fconfiguration" is of type xml but expression is of type character varying
  Hint: You will need to rewrite or cast the expression.
  Position: 172 {prepstmnt 2057332087 INSERT INTO cu7user.Run (runid,
fconfiguration, enddate, startdate, name, finputcatalog_catalogid,
finputrun_runid, foutputcatalog_catalogid, fuser_fusername) VALUES (?, ?, ?,
?, ?, ?, ?, ?, ?) [params=?, ?, ?, ?, ?, ?, ?, ?, ?]} [code=0, state=42804]
FailedObject: gaia.cu7.om.Run@799ac2e3
	at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4869)
	at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4829)
	at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:136)
	at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:78)
	at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushBatch(BatchingPreparedStatementManagerImpl.java:217)
	at
org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:63)
	at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:103)
	at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:76)
	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:742)
	at
org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
	at
org.apache.openjpa.datacache.DataCacheStoreManager.flush(DataCacheStoreManager.java:661)
	at
org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
	... 34 more
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR: column
"fconfiguration" is of type xml but expression is of type character varying
  Hint: You will need to rewrite or cast the expression.
  Position: 172 {prepstmnt 2057332087 INSERT INTO cu7user.Run (runid,
fconfiguration, enddate, startdate, name, finputcatalog_catalogid,
finputrun_runid, foutputcatalog_catalogid, fuser_fusername) VALUES (?, ?, ?,
?, ?, ?, ?, ?, ?) [params=?, ?, ?, ?, ?, ?, ?, ?, ?]} [code=0, state=42804]
	at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:281)
	at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:257)
	at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$1000(LoggingConnectionDecorator.java:72)
	at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:1199)
	at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:291)
	at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:291)
	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1776)
	at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(PreparedStatementManagerImpl.java:267)
	at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushSingleRow(BatchingPreparedStatementManagerImpl.java:246)
	at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushBatch(BatchingPreparedStatementManagerImpl.java:155)
	... 41 more

</Exception2>

Best regards,
Krzysztof


--
View this message in context: http://openjpa.208410.n2.nabble.com/XMLValueHandler-strategy-not-supported-in-Postgres-tp6331286p6331286.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Proxy of custom strategy nullifies all its fields -was:XMLValueHandler strategy not supported in Postgres?

Posted by Krzysztof <ya...@gmail.com>.
Yes indeed!
What is interesting it was enough to just add setters to the root object,
all nested levels are populated properly.

Big thanks for the hints!

--
View this message in context: http://openjpa.208410.n2.nabble.com/XMLValueHandler-strategy-not-supported-in-Postgres-tp6331286p6337408.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Proxy of custom strategy nullifies all its fields -was:XMLValueHandler strategy not supported in Postgres?

Posted by Miłosz Tylenda <mt...@o2.pl>.
Krzysztof,

I think the missing setters is the problem even if you use XmlAccessType.FIELD. Add the setters and try it. You can also check what happens if you switch to XmlAccessType.PROPERTY. The user manual mentions some JAXB plugins which could generate setters [1].

Milosz

[1] http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_xmlmapping

> Milosz,
> Will try now with 8.3jdbc3 that is included with openjpa. I have been using
> jdbc4 for a while without any problems (no XML however). 
> 
> JAXB classes use @XmlAccessorType(XmlAccessType.FIELD) everywhere - so there
> are getters, no setters. Do you think this could be a problem?
> 
> I tried to test the snapshot sources with PG9 but it did not build for me,
> some problem with openbooks example (tried on OSX).
> 
> ...
> [INFO] OpenJPA JEST ...................................... SUCCESS [1.771s]
> [INFO] OpenJPA Aggregate Jar ............................. SUCCESS [6.712s]
> [INFO] OpenJPA Aggregate Jar with Dependencies ........... SUCCESS [3.900s]
> [INFO] OpenJPA Project Docs and Assemblies ............... SUCCESS [25.596s]
> [INFO] OpenJPA Examples .................................. SUCCESS [0.061s]
> [INFO] OpenJPA Examples - Simple ......................... SUCCESS [1.174s]
> [INFO] OpenJPA Examples - image-gallery .................. SUCCESS [1.802s]
> [INFO] OpenJPA Examples - OpenBooks ...................... FAILURE [0.424s]
> [INFO] OpenJPA Integration Tests ......................... SKIPPED
> [INFO] OpenJPA Integration Tests - Daytrader ............. SKIPPED
> [INFO] OpenJPA Integration Tests - Examples .............. SKIPPED
> [INFO] OpenJPA Integration Tests - SLF4JLogFactory ....... SKIPPED
> [INFO] OpenJPA Integration Tests - JPA TCK ............... SKIPPED
> [INFO] OpenJPA Integration Tests - Bean Validation ....... SKIPPED
> [INFO] OpenJPA Integration Tests - JMX Platform MBeans ... SKIPPED
> [INFO] OpenJPA tools ..................................... SKIPPED
> [INFO] OpenJPA Maven Plugin .............................. SKIPPED
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 2:25.570s
> [INFO] Finished at: Fri May 06 13:04:43 CEST 2011
> [INFO] Final Memory: 49M/240M
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-antrun-plugin:1.3:run (genmodel) on project
> openbooks: An Ant BuildException has occured: The following error occurred
> while executing this line:
> [ERROR]
> /Users/knienart/gaia/openjpa/openjpa-examples/openbooks/build.xml:116: ***
> Error:
> [ERROR] The directory for OpenJPA libraries can not be located at
> /Users/knienart/.m2/repository/org/apache/openjpa/openjpa-all/2.2.0-SNAPSHOT.
> [ERROR] Make sure openjpa.lib property value is correct in build.properties
> file.
> [ERROR] -> [Help 1]
> [ERROR] 
> [ERROR] To see the full stack trace of the errors, re-run Maven with the -e
> switch.
> [ERROR] Re-run Maven using the -X switch to enable full debug logging.
> [ERROR] 
> [ERROR] For more information about the errors and possible solutions, please
> read the following articles:
> [ERROR] [Help 1]
> http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
> [ERROR] 
> [ERROR] After correcting the problems, you can resume the build with the
> command
> [ERROR]   mvn <goals> -rf :openbooks
> 
> --
> View this message in context: http://openjpa.208410.n2.nabble.com/XMLValueHandler-strategy-not-supported-in-Postgres-tp6331286p6337236.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> 

Re: Proxy of custom strategy nullifies all its fields - was:XMLValueHandler strategy not supported in Postgres?

Posted by Krzysztof <ya...@gmail.com>.
Milosz,
Will try now with 8.3jdbc3 that is included with openjpa. I have been using
jdbc4 for a while without any problems (no XML however). 

JAXB classes use @XmlAccessorType(XmlAccessType.FIELD) everywhere - so there
are getters, no setters. Do you think this could be a problem?

I tried to test the snapshot sources with PG9 but it did not build for me,
some problem with openbooks example (tried on OSX).

...
[INFO] OpenJPA JEST ...................................... SUCCESS [1.771s]
[INFO] OpenJPA Aggregate Jar ............................. SUCCESS [6.712s]
[INFO] OpenJPA Aggregate Jar with Dependencies ........... SUCCESS [3.900s]
[INFO] OpenJPA Project Docs and Assemblies ............... SUCCESS [25.596s]
[INFO] OpenJPA Examples .................................. SUCCESS [0.061s]
[INFO] OpenJPA Examples - Simple ......................... SUCCESS [1.174s]
[INFO] OpenJPA Examples - image-gallery .................. SUCCESS [1.802s]
[INFO] OpenJPA Examples - OpenBooks ...................... FAILURE [0.424s]
[INFO] OpenJPA Integration Tests ......................... SKIPPED
[INFO] OpenJPA Integration Tests - Daytrader ............. SKIPPED
[INFO] OpenJPA Integration Tests - Examples .............. SKIPPED
[INFO] OpenJPA Integration Tests - SLF4JLogFactory ....... SKIPPED
[INFO] OpenJPA Integration Tests - JPA TCK ............... SKIPPED
[INFO] OpenJPA Integration Tests - Bean Validation ....... SKIPPED
[INFO] OpenJPA Integration Tests - JMX Platform MBeans ... SKIPPED
[INFO] OpenJPA tools ..................................... SKIPPED
[INFO] OpenJPA Maven Plugin .............................. SKIPPED
[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 2:25.570s
[INFO] Finished at: Fri May 06 13:04:43 CEST 2011
[INFO] Final Memory: 49M/240M
[INFO]
------------------------------------------------------------------------
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-antrun-plugin:1.3:run (genmodel) on project
openbooks: An Ant BuildException has occured: The following error occurred
while executing this line:
[ERROR]
/Users/knienart/gaia/openjpa/openjpa-examples/openbooks/build.xml:116: ***
Error:
[ERROR] The directory for OpenJPA libraries can not be located at
/Users/knienart/.m2/repository/org/apache/openjpa/openjpa-all/2.2.0-SNAPSHOT.
[ERROR] Make sure openjpa.lib property value is correct in build.properties
file.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e
switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please
read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the
command
[ERROR]   mvn <goals> -rf :openbooks

--
View this message in context: http://openjpa.208410.n2.nabble.com/XMLValueHandler-strategy-not-supported-in-Postgres-tp6331286p6337236.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Proxy of custom strategy nullifies all its fields - was:XMLValueHandler strategy not supported in Postgres?

Posted by Miłosz Tylenda <mt...@o2.pl>.
Krzysztof,

Did you try your case with OpenJPA-provided XMLValueHandler and a JDBC driver from 8.x line?

Does your JAXB entity have setters for all persistent fields and collections?

Cheers,
Milosz


> Hi Milosz,
> Thanks for the hints.
> Actually I was too quick with reporting success: storing xml works
> perfectly, but retrieval is broken.
> 
> I can see that even my XMLValueHandler returns proper unmarshaled object,
> all fields are nullified by MyTypeHoldingXML.pcReplaceField(int) of the xml
> field.
> This happens both on detachement/commit and retrieval - I can see object is
> replaced with a proxy that has all values null.
> 
> 
> Thread [main] (Suspended (breakpoint at line 2201 in StateManagerImpl))	
> 	StateManagerImpl.replaceObjectField(PersistenceCapable, int) line: 2201	
> 	Run&lt;INPUT,OUTPUT&gt;.pcReplaceField(int) line: not available
> <-------this nullifies XML field by creating proxy with all fields being
> null
> 	StateManagerImpl.replaceField(PersistenceCapable, FieldManager, int) line:
> 3161	
> 	StateManagerImpl.storeObjectField(int, Object) line: 2596	
> 	StateManagerImpl.storeField(int, Object, FieldManager) line: 2692	
> 	StateManagerImpl.storeField(int, Object) line: 875	
> 	StateManagerImpl.store(int, Object) line: 871	
> 	HandlerFieldStrategy.load(OpenJPAStateManager, JDBCStore,
> JDBCFetchConfiguration, Result) line: 189	
> 	FieldMapping.load(OpenJPAStateManager, JDBCStore, JDBCFetchConfiguration,
> Result) line: 928	
> 	JDBCStoreManager.load(ClassMapping, OpenJPAStateManager,
> JDBCFetchConfiguration, Result, FieldMapping) line: 1123	
> 	JDBCStoreManager.load(ClassMapping, OpenJPAStateManager,
> JDBCFetchConfiguration, Result) line: 1067	
> 	JDBCStoreManager.initializeState(OpenJPAStateManager, PCState,
> JDBCFetchConfiguration, ConnectionInfo) line: 438	
> 	JDBCStoreManager.initialize(OpenJPAStateManager, PCState,
> FetchConfiguration, Object) line: 333	
> 
> DataCacheStoreManager(DelegatingStoreManager).initialize(OpenJPAStateManager,
> PCState, FetchConfiguration, Object) line: 112	
> 	DataCacheStoreManager.initialize(OpenJPAStateManager, PCState,
> FetchConfiguration, Object) line: 360	
> 	ROPStoreManager(DelegatingStoreManager).initialize(OpenJPAStateManager,
> PCState, FetchConfiguration, Object) line: 112	
> 	ROPStoreManager.initialize(OpenJPAStateManager, PCState,
> FetchConfiguration, Object) line: 57	
> 	FinalizingBrokerImpl(BrokerImpl).initialize(StateManagerImpl, boolean,
> FetchConfiguration, Object) line: 1022	
> 	FinalizingBrokerImpl(BrokerImpl).find(Object, FetchConfiguration, BitSet,
> Object, int, FindCallbacks) line: 980	
> 	FinalizingBrokerImpl(BrokerImpl).find(Object, boolean, FindCallbacks) line:
> 897	
> 	DelegatingBroker.find(Object, boolean, FindCallbacks) line: 223	
> 	EntityManagerImpl.find(Class<T>, Object) line: 478	
> 	
> 
> 
> I will create Jira but this is quite urgent so would appreciate any
> suggestions..
> Best regards,
> Krzysztof
> 
> --
> View this message in context: http://openjpa.208410.n2.nabble.com/XMLValueHandler-strategy-not-supported-in-Postgres-tp6331286p6337026.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> 

Proxy of custom strategy nullifies all its fields - was: XMLValueHandler strategy not supported in Postgres?

Posted by Krzysztof <ya...@gmail.com>.
Hi Milosz,
Thanks for the hints.
Actually I was too quick with reporting success: storing xml works
perfectly, but retrieval is broken.

I can see that even my XMLValueHandler returns proper unmarshaled object,
all fields are nullified by MyTypeHoldingXML.pcReplaceField(int) of the xml
field.
This happens both on detachement/commit and retrieval - I can see object is
replaced with a proxy that has all values null.


Thread [main] (Suspended (breakpoint at line 2201 in StateManagerImpl))	
	StateManagerImpl.replaceObjectField(PersistenceCapable, int) line: 2201	
	Run&lt;INPUT,OUTPUT&gt;.pcReplaceField(int) line: not available
<-------this nullifies XML field by creating proxy with all fields being
null
	StateManagerImpl.replaceField(PersistenceCapable, FieldManager, int) line:
3161	
	StateManagerImpl.storeObjectField(int, Object) line: 2596	
	StateManagerImpl.storeField(int, Object, FieldManager) line: 2692	
	StateManagerImpl.storeField(int, Object) line: 875	
	StateManagerImpl.store(int, Object) line: 871	
	HandlerFieldStrategy.load(OpenJPAStateManager, JDBCStore,
JDBCFetchConfiguration, Result) line: 189	
	FieldMapping.load(OpenJPAStateManager, JDBCStore, JDBCFetchConfiguration,
Result) line: 928	
	JDBCStoreManager.load(ClassMapping, OpenJPAStateManager,
JDBCFetchConfiguration, Result, FieldMapping) line: 1123	
	JDBCStoreManager.load(ClassMapping, OpenJPAStateManager,
JDBCFetchConfiguration, Result) line: 1067	
	JDBCStoreManager.initializeState(OpenJPAStateManager, PCState,
JDBCFetchConfiguration, ConnectionInfo) line: 438	
	JDBCStoreManager.initialize(OpenJPAStateManager, PCState,
FetchConfiguration, Object) line: 333	

DataCacheStoreManager(DelegatingStoreManager).initialize(OpenJPAStateManager,
PCState, FetchConfiguration, Object) line: 112	
	DataCacheStoreManager.initialize(OpenJPAStateManager, PCState,
FetchConfiguration, Object) line: 360	
	ROPStoreManager(DelegatingStoreManager).initialize(OpenJPAStateManager,
PCState, FetchConfiguration, Object) line: 112	
	ROPStoreManager.initialize(OpenJPAStateManager, PCState,
FetchConfiguration, Object) line: 57	
	FinalizingBrokerImpl(BrokerImpl).initialize(StateManagerImpl, boolean,
FetchConfiguration, Object) line: 1022	
	FinalizingBrokerImpl(BrokerImpl).find(Object, FetchConfiguration, BitSet,
Object, int, FindCallbacks) line: 980	
	FinalizingBrokerImpl(BrokerImpl).find(Object, boolean, FindCallbacks) line:
897	
	DelegatingBroker.find(Object, boolean, FindCallbacks) line: 223	
	EntityManagerImpl.find(Class<T>, Object) line: 478	
	


I will create Jira but this is quite urgent so would appreciate any
suggestions..
Best regards,
Krzysztof

--
View this message in context: http://openjpa.208410.n2.nabble.com/XMLValueHandler-strategy-not-supported-in-Postgres-tp6331286p6337026.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: XMLValueHandler strategy not supported in Postgres?

Posted by Miłosz Tylenda <mt...@o2.pl>.
Hi Krzysztof,

It is interesting since OpenJPA source contains a test case for XML mapping [1] and it was passing when I last ran it on PostgreSQL. Most likely it is because I have got PostgreSQL 8.3 and some 8.* driver. It also passed with some other databases. Is it possible that you give it a try with an 8.3 or 8.4 driver, assuming it works with PostgreSQL 9?

Anyway, you could open a JIRA issue, so that PostgreSQL support gets up to date.

Regards,
Milosz

[1] https://fisheye6.atlassian.com/browse/~br=trunk/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping?r=1004043


> Seems I resolved these two problems by changing java type to PC_UNTYPED and
> type to SQLXML in slightly changed XMLValueHandler from openjpa source tree:
> 
>      public Column[] map(ValueMapping vm, DBIdentifier name, ColumnIO io,
>         boolean adapt) {
>         Column col = new Column();
>         col.setIdentifier(name);
>         col.setJavaType(JavaTypes.PC_UNTYPED); //was JavaTypes.STRING
>         col.setSize(-1);
>        
> col.setTypeIdentifier(DBIdentifier.newColumnDefinition(vm.getMappingRepository().getDBDictionary()
>             .xmlTypeName));
>         col.setXML(true);
>         col.setType(Types.SQLXML);	// new, otherwise CLOB is picked up. 
>         return new Column[]{ col };
>     }
> 
> I'm not sure how generic is this though.
> 
> XML is stored and reconstructed JAXB objects look ok now.
> Krzysztof
> 
> --
> View this message in context: http://openjpa.208410.n2.nabble.com/XMLValueHandler-strategy-not-supported-in-Postgres-tp6331286p6331526.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> 

Re: XMLValueHandler strategy not supported in Postgres?

Posted by Krzysztof <ya...@gmail.com>.
Seems I resolved these two problems by changing java type to PC_UNTYPED and
type to SQLXML in slightly changed XMLValueHandler from openjpa source tree:

     public Column[] map(ValueMapping vm, DBIdentifier name, ColumnIO io,
        boolean adapt) {
        Column col = new Column();
        col.setIdentifier(name);
        col.setJavaType(JavaTypes.PC_UNTYPED); //was JavaTypes.STRING
        col.setSize(-1);
       
col.setTypeIdentifier(DBIdentifier.newColumnDefinition(vm.getMappingRepository().getDBDictionary()
            .xmlTypeName));
        col.setXML(true);
        col.setType(Types.SQLXML);	// new, otherwise CLOB is picked up. 
        return new Column[]{ col };
    }

I'm not sure how generic is this though.

XML is stored and reconstructed JAXB objects look ok now.
Krzysztof

--
View this message in context: http://openjpa.208410.n2.nabble.com/XMLValueHandler-strategy-not-supported-in-Postgres-tp6331286p6331526.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.