Dear Folks,
I have currently problems setting up the classpath of SchemaExporter. It does not likes my custom EnumType class. The class is in classpath of eclipse and in classpath of maven.
First of all it tried the wonderful maven-hibernate plugin which works great most of the cases, but fails to load the EnunType class.
The I fall back and tried to use the SchemaExporter manually. I have the same result:
Code:
Configuration configuration = new Configuration();
Properties properties = new Properties();
properties.load( SchemaExporter.class.getResourceAsStream("/hibernate.properties"));
configuration.setProperties(properties);
configuration.addClass(Accountablity.class);
configuration.addClass(SentinelUser.class);
configuration.addClass(Area.class);
configuration.addClass(Contact.class);
configuration.addClass(Customer.class);
configuration.addClass(CustomerGroup.class);
configuration.addClass(DoctorsOffice.class);
configuration.addClass(Drugstore.class);
configuration.addClass(Hospital.class);
configuration.addClass(Pharmaceutics.class);
configuration.addClass(Region.class);
new SchemaExport(configuration).create(true, false);
and here is the exception:
Code:
16:34:01,102 INFO Environment:432 - Hibernate 2.1.1
16:34:01,182 INFO Environment:466 - loaded properties from resource hibernate.properties: {hibernate.query.substitutions=yes 'Y', no 'N', hibernate.cache.region_prefix=turbine.sentinel, hibernate.show_sql=true, hibernate.proxool.pool_alias=pool1, hibernate.jdbc.batch_size=0, hibernate.jdbc.fetch_size=25, hibernate.cache.use_query_cache=true, hibernate.jdbc.use_streams_for_binary=true, hibernate.max_fetch_depth=1, hibernate.use_outer_join=true, hibernate.connection.pool_size=1, hibernate.connection.username=tobias.rademacher, hibernate.connection.driver_class=org.postgresql.Driver, hibernate.cache.provider_class=net.sf.hibernate.cache.OSCacheProvider, hibernate.cglib.use_reflection_optimizer=true, hibernate.transaction.factory_class=net.sf.hibernate.transaction.JDBCTransactionFactory, hibernate.dialect=net.sf.hibernate.dialect.PostgreSQLDialect, hibernate.connection.url=jdbc:postgresql://localhost/apogee_domain_model/}
16:34:01,192 INFO Environment:480 - using java.io streams to persist binary types
16:34:01,202 INFO Environment:481 - using CGLIB reflection optimizer
16:34:01,232 INFO Configuration:318 - Mapping resource: innowake/apogee/domain/model/accountability/Accountablity.hbm.xml
16:34:01,763 INFO Binder:225 - Mapping class: innowake.apogee.domain.model.accountability.Accountablity -> ACCOUNTABLITY
16:34:02,063 INFO Binder:534 - Mapping collection: innowake.apogee.domain.model.accountability.Accountablity.subordinates -> subordinates
16:34:02,183 INFO Binder:200 - Mapping joined-subclass: innowake.apogee.domain.model.master.CustomerGroup -> CUSTOMER_GROUP
16:34:02,203 INFO Configuration:318 - Mapping resource: innowake/turbine/sentinel/model/SentinelUser.hbm.xml
16:34:02,313 INFO Binder:225 - Mapping class: innowake.turbine.sentinel.model.SentinelUser -> TURBINE_USER
16:34:02,353 INFO Binder:200 - Mapping joined-subclass: innowake.apogee.domain.model.accountability.Person -> PERSON
16:34:02,353 INFO Configuration:318 - Mapping resource: innowake/apogee/domain/model/master/Area.hbm.xml
16:34:02,514 INFO Binder:225 - Mapping class: innowake.apogee.domain.model.master.Area -> AREA
16:34:02,514 INFO Binder:534 - Mapping collection: innowake.apogee.domain.model.master.Area.pharamIdentifiers -> AREA_PHARMACEUTICS_ASSIGNMENT
16:34:02,524 INFO Configuration:318 - Mapping resource: innowake/apogee/domain/model/master/Contact.hbm.xml
16:34:02,594 INFO Binder:225 - Mapping class: innowake.apogee.domain.model.master.Contact -> CONTACT
16:34:02,684 ERROR Configuration:250 - Could not compile the mapping document
net.sf.hibernate.MappingException: Cannot instantiate custom type: innowake.hibernate.customizing.EnumType
at net.sf.hibernate.type.CustomType.<init>(CustomType.java:38)
at net.sf.hibernate.type.TypeFactory.heuristicType(TypeFactory.java:163)
at net.sf.hibernate.cfg.Binder.getTypeFromXML(Binder.java:894)
at net.sf.hibernate.cfg.Binder.bindSimpleValue(Binder.java:403)
at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:1008)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:344)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1204)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:247)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:281)
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:322)
at innowake.hibernate.SchemaExporter.main(SchemaExporter.java:50)
net.sf.hibernate.MappingException: Error reading resource: innowake/apogee/domain/model/master/Contact.hbm.xml
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:325)
at innowake.hibernate.SchemaExporter.main(SchemaExporter.java:50)
Caused by: net.sf.hibernate.MappingException: Cannot instantiate custom type: innowake.hibernate.customizing.EnumType
at net.sf.hibernate.type.CustomType.<init>(CustomType.java:38)
at net.sf.hibernate.type.TypeFactory.heuristicType(TypeFactory.java:163)
at net.sf.hibernate.cfg.Binder.getTypeFromXML(Binder.java:894)
at net.sf.hibernate.cfg.Binder.bindSimpleValue(Binder.java:403)
at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:1008)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:344)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1204)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:247)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:281)
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:322)
... 1 more
Exception in thread "main"
How do I deal with custom types and SchemaExport?
Any help is highly appricated ;)
Lot's of thx.
Toby