-->
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.  [ 1 post ] 
Author Message
 Post subject: MappingException from Oracle xmltype to W3C Dom Document
PostPosted: Fri Sep 18, 2009 7:41 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
I have written a custom mapping to go from Oracle 11g's proprietary xmltype data type to org.w3c.dom.Document and back again. I have applied this mapping in my POJO as follows:

Code:
@Column(name = "DOC_XML", nullable = false)
    @org.hibernate.annotations.Type(type = "persistence.oracle.xml.OracleXmlMapping")
    public Document getText() {
        return text;
    }

    public void setText(Document text) {
        this.text = text;
    }


In my IDE IntelliJ I get a red squiggly line under Document (the return type of the getter) saying "'unknown' attribute type is invalid." More generally though, when I compile and then run Hibernate Tools in Maven, I get the following exception:

Code:
org.hibernate.MappingException: Could not determine type for: persistence.oracle.xml.OracleXmlMapping, at table: DOC_XML, for columns: [org.hibernate.mapping.Column(DOC_XML)]
   at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:292)
   at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:161)
   at org.hibernate.mapping.Column.getSqlType(Column.java:205)
   at org.hibernate.mapping.Table.sqlCreateString(Table.java:420)
   at org.hibernate.cfg.Configuration.generateSchemaCreationScript(Configuration.java:881)
   at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:129)
   at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:91)
   at org.codehaus.mojo.hibernate3.exporter.Hbm2DDLExporterMojo.doExecute(Hbm2DDLExporterMojo.java:96)
   at org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:152)
   at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
   at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
   at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:540)
   at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:519)
   at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
   at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
   at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
   at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
   at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
   at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
   at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:41)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
   at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
   at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
   at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)


Incidentally, in my OracleXMLMapping custom mapping class, I have the following:

Code:
private static final int[] SQL_TYPES = new int[]{oracle.xdb.XMLType._SQL_TYPECODE};


If I just try to run tests by bypassing Hibernate Tools, I get this:

Code:
Caused by: java.lang.NoClassDefFoundError: persistence/oracle/xml/OracleXmlMapping (wrong name: persistence/oracle/xml/OracleXMLMapping)
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
   at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
   at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
   at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:169)
   at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
   at org.hibernate.type.TypeFactory.heuristicType(TypeFactory.java:223)
   at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:260)
   at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
   at org.hibernate.mapping.Property.isValid(Property.java:185)
   at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:440)
   at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
   at org.hibernate.cfg.Configuration.validate(Configuration.java:1108)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1293)
   at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
   at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
   at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
   at org.springframework.orm.jpa.LocalEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalEntityManagerFactoryBean.java:91)
   at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:291)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)


I checked and found that the class is found in my classpath in the target folder.

This has been baffling me since I have implemented a similar mapping for Oracle Spatial's datatype, which is more complicated yet works great.

Any insight is appreciated.

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.