I've added foreign key (for the 1st. time...) and getting "Unable to build EntityManagerFactory" exception. Any ideas what is the problem?
The JOBS.COMPANY_ID is defined as foreign key to COMPANIES.COMPANY_ID
Hibernate Mapping - Companies <class name="jobpro.Company" table="COMPANIES"> <id name="id" column="COMPANY_ID"> <generator class="native"/> </id> <property name="name" column="NAME"/> <property name="url" column="URL"/> </class>
Java Class - Company public class Company { // Properties private Long id; private String name; private String url; public Company() { } // Getters / Setters... }
Hibernate Mapping - JOBS <class name="jobpro.Job" table="JOBS"> <id name="id" column="ID"> <generator class="native"/> </id> <property name="title" column="TITLE"/> <many-to-one name="company" class="Company" column="COMPANY_ID" not-null="true"/> <query name="JOBS.findAll"><![CDATA[from Job]]></query> </class>
Java Class - Job public class Job { // Properties private Long id; private String title; private Company company; public Job() { } // Getters / Setters.... }
NOT SURE IF USEFULL, BUT HERE IS AN EXCREPT FROM THE LOG 09:14:02.285 DEBUG profound.util.HibernateUtil - buildProfoundEMFactory() - start 09:14:02.402 INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.4.0.GA 09:14:02.446 INFO org.hibernate.cfg.Environment - Hibernate 3.3.2.GA 09:14:02.455 INFO org.hibernate.cfg.Environment - hibernate.properties not found 09:14:02.463 INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist 09:14:02.477 INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling 09:14:02.697 INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.1.0.GA 09:14:02.713 INFO org.hibernate.ejb.Version - Hibernate EntityManager 3.4.0.GA 09:14:02.772 DEBUG org.hibernate.ejb.Ejb3Configuration - Look up for persistence unit: profound_db 09:14:02.829 DEBUG org.hibernate.util.DTDEntityResolver - trying to resolve system-id [http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd] 09:14:02.830 DEBUG org.hibernate.cfg.EJB3DTDEntityResolver - recognized EJB3 ORM namespace; attempting to resolve on classpath under org/hibernate/ejb 09:14:02.833 DEBUG org.hibernate.cfg.EJB3DTDEntityResolver - located [http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd] in classpath 09:14:02.876 DEBUG org.hibernate.ejb.Ejb3Configuration - Detect class: true; detect hbm: true 09:14:02.907 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - Searching mapped entities in jar/par: file:/C:/ADC/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ProfoundBeta/WEB-INF/classes/ 09:14:02.910 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: jobpro.Company 09:14:03.004 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: jobpro.IUserManager 09:14:03.006 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: jobpro.Job 09:14:03.008 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: jobpro.JobProService 09:14:03.033 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: jobpro.User 09:14:03.035 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: jobpro.UserManager 09:14:03.039 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - File Filter matched for META-INF/Company.hbm.xml 09:14:03.043 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - File Filter matched for META-INF/Job.hbm.xml 09:14:03.048 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - File Filter matched for META-INF/User.hbm.xml 09:14:03.050 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: profound.portfolio.Project 09:14:03.054 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: profound.portfolio.ProjectService 09:14:03.065 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: profound.portfolio.Skill 09:14:03.069 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: profound.util.HibernateUtil 09:14:03.073 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: utils.AbstractFactory 09:14:03.077 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: utils.Factory 09:14:03.080 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: utils.FactoryMaker 09:14:03.083 DEBUG org.hibernate.ejb.packaging.AbstractJarVisitor - Filtering: utils.UtilsService 09:14:03.086 DEBUG org.hibernate.ejb.Ejb3Configuration - Detect class: true; detect hbm: true 09:14:03.087 DEBUG org.hibernate.ejb.Ejb3Configuration - Creating Factory: profound_db 09:14:03.167 DEBUG org.hibernate.util.DTDEntityResolver - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] 09:14:03.172 DEBUG org.hibernate.util.DTDEntityResolver - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/ 09:14:03.174 DEBUG org.hibernate.util.DTDEntityResolver - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath 09:14:03.243 DEBUG org.hibernate.util.DTDEntityResolver - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] 09:14:03.244 DEBUG org.hibernate.util.DTDEntityResolver - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/ 09:14:03.244 DEBUG org.hibernate.util.DTDEntityResolver - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath 09:14:03.283 DEBUG org.hibernate.util.DTDEntityResolver - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] 09:14:03.284 DEBUG org.hibernate.util.DTDEntityResolver - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/ 09:14:03.285 DEBUG org.hibernate.util.DTDEntityResolver - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath 09:14:03.304 DEBUG org.hibernate.cfg.AnnotationConfiguration - Execute first pass mapping processing 09:14:03.405 DEBUG org.hibernate.cfg.AnnotationConfiguration - Process hbm files 09:14:03.447 INFO org.hibernate.cfg.HbmBinder - Mapping class: jobpro.Company -> COMPANIES 09:14:03.488 DEBUG org.hibernate.cfg.HbmBinder - Mapped property: id -> COMPANY_ID 09:14:03.516 DEBUG org.hibernate.cfg.HbmBinder - Mapped property: name -> NAME 09:14:03.520 DEBUG org.hibernate.cfg.HbmBinder - Mapped property: url -> URL 09:14:03.521 INFO org.hibernate.cfg.HbmBinder - Mapping class: jobpro.User -> users 09:14:03.524 DEBUG org.hibernate.cfg.HbmBinder - Mapped property: id -> USER_ID 09:14:03.524 DEBUG org.hibernate.cfg.HbmBinder - Mapped property: userName -> USER_NAME 09:14:03.525 DEBUG org.hibernate.cfg.HbmBinder - Mapped property: password -> PASSWORD 09:14:03.529 DEBUG org.hibernate.cfg.HbmBinder - Named query: jobpro.User.users.byUNnPWD -> SELECT u from User u where u.userName=? and u.password=? 09:14:03.532 INFO org.hibernate.cfg.HbmBinder - Mapping class: jobpro.Job -> JOBS 09:14:03.535 DEBUG org.hibernate.cfg.HbmBinder - Mapped property: id -> ID 09:14:03.536 DEBUG org.hibernate.cfg.HbmBinder - Mapped property: title -> TITLE 09:14:03.691 DEBUG org.hibernate.cfg.HbmBinder - Mapped property: company -> COMPANY_ID 09:14:03.691 DEBUG org.hibernate.cfg.HbmBinder - Named query: jobpro.Job.JOBS.findAll -> from Job 09:14:03.692 DEBUG org.hibernate.cfg.AnnotationConfiguration - Process annotated classes 09:14:03.693 DEBUG org.hibernate.cfg.AnnotationConfiguration - processing fk mappings (*ToOne and JoinedSubclass) 09:14:03.693 DEBUG org.hibernate.cfg.Configuration - processing extends queue 09:14:03.694 DEBUG org.hibernate.cfg.Configuration - processing collection mappings 09:14:03.695 DEBUG org.hibernate.cfg.Configuration - processing native query and ResultSetMapping mappings 09:14:03.695 DEBUG org.hibernate.cfg.Configuration - processing association property references 09:14:03.696 DEBUG org.hibernate.cfg.Configuration - processing foreign key constraints 09:14:03.700 DEBUG org.hibernate.cfg.Configuration - resolving reference to class: jobpro.Company 09:14:03.720 INFO org.hibernate.validator.Version - Hibernate Validator 3.1.0.GA 09:14:03.738 DEBUG org.hibernate.validator.ClassValidator - ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages 09:14:03.784 DEBUG org.hibernate.validator.ClassValidator - ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages 09:14:03.786 DEBUG org.hibernate.validator.ClassValidator - ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages 09:14:03.842 DEBUG org.hibernate.ejb.util.NamingHelper - No JNDI name configured for binding Ejb3Configuration 09:14:03.856 DEBUG org.hibernate.cfg.search.HibernateSearchEventListenerRegister - Search not present in classpath, ignoring event listener registration. 09:14:03.857 INFO org.hibernate.cfg.search.HibernateSearchEventListenerRegister - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled. 09:14:03.858 DEBUG org.hibernate.cfg.Configuration - Preparing to build session factory with filters : {} 09:14:03.859 DEBUG org.hibernate.cfg.AnnotationConfiguration - Execute first pass mapping processing 09:14:03.859 DEBUG org.hibernate.cfg.AnnotationConfiguration - Process hbm files 09:14:03.860 DEBUG org.hibernate.cfg.AnnotationConfiguration - Process annotated classes 09:14:03.862 DEBUG org.hibernate.cfg.AnnotationConfiguration - processing fk mappings (*ToOne and JoinedSubclass) 09:14:03.862 DEBUG org.hibernate.cfg.Configuration - processing extends queue 09:14:03.863 DEBUG org.hibernate.cfg.Configuration - processing collection mappings 09:14:03.863 DEBUG org.hibernate.cfg.Configuration - processing native query and ResultSetMapping mappings 09:14:03.864 DEBUG org.hibernate.cfg.Configuration - processing association property references 09:14:03.864 DEBUG org.hibernate.cfg.Configuration - processing foreign key constraints 09:14:03.865 DEBUG org.hibernate.cfg.Configuration - resolving reference to class: jobpro.Company 09:14:03.866 DEBUG org.hibernate.validator.ClassValidator - ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages 09:14:03.867 DEBUG org.hibernate.validator.ClassValidator - ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages 09:14:03.868 DEBUG org.hibernate.validator.ClassValidator - ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages 09:14:03.883 INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!) 09:14:03.884 INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 6 09:14:03.886 INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: true 09:14:04.003 INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/profound 09:14:04.004 INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {autoReconnect=true, user=root, password=, autocommit=true, release_mode=auto} 09:14:04.005 DEBUG org.hibernate.connection.DriverManagerConnectionProvider - opening new JDBC connection 09:14:04.423 DEBUG org.hibernate.connection.DriverManagerConnectionProvider - created connection to: jdbc:mysql://localhost/profound, Isolation Level: 4 09:14:04.423 INFO org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 5.0.90-community 09:14:04.424 INFO org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.11 ( Revision: ${svn.Revision} ) 09:14:04.487 INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLInnoDBDialect 09:14:04.496 INFO org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory 09:14:04.500 INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 09:14:04.501 INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled 09:14:04.503 INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled 09:14:04.503 INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15 09:14:04.504 INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled 09:14:04.506 INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled 09:14:04.507 DEBUG org.hibernate.cfg.SettingsFactory - Wrap result sets: disabled 09:14:04.507 INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled 09:14:04.508 INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto 09:14:04.510 INFO org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2 09:14:04.511 INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1 09:14:04.512 INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: enabled 09:14:04.513 INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled 09:14:04.515 INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled 09:14:04.516 INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.classic.ClassicQueryTranslatorFactory 09:14:04.521 INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {} 09:14:04.521 INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: enabled 09:14:04.522 INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled 09:14:04.522 INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled 09:14:04.523 INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory 09:14:04.523 INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled 09:14:04.526 INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled 09:14:04.547 INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout 09:14:04.549 INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled 09:14:04.550 INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled 09:14:04.551 INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo 09:14:04.551 INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled 09:14:04.599 DEBUG org.hibernate.validator.ClassValidator - ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages 09:14:04.602 DEBUG org.hibernate.validator.ClassValidator - ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages 09:14:04.603 DEBUG org.hibernate.validator.ClassValidator - ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages 09:14:04.668 INFO org.hibernate.impl.SessionFactoryImpl - building session factory 09:14:04.675 DEBUG org.hibernate.impl.SessionFactoryImpl - Session factory constructed with filter configurations : {} 09:14:04.676 DEBUG org.hibernate.impl.SessionFactoryImpl - instantiating session factory with properties: {java.vendor=Sun Microsystems Inc., sun.java.launcher=SUN_STANDARD, catalina.base=C:\ADC\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0, hibernate.connection.url=jdbc:mysql://localhost/profound, sun.management.compiler=HotSpot Client Compiler, hibernate.ejb.discard_pc_on_close=false, catalina.useNaming=true, hibernate.transaction.flush_before_completion=false, os.name=Windows Vista, sun.boot.class.path=C:\Program Files\Java\jre1.6.0_06\lib\resources.jar;C:\Program Files\Java\jre1.6.0_06\lib\rt.jar;C:\Program Files\Java\jre1.6.0_06\lib\sunrsasign.jar;C:\Program Files\Java\jre1.6.0_06\lib\jsse.jar;C:\Program Files\Java\jre1.6.0_06\lib\jce.jar;C:\Program Files\Java\jre1.6.0_06\lib\charsets.jar;C:\Program Files\Java\jre1.6.0_06\classes, sun.desktop=windows, java.vm.specification.vendor=Sun Microsystems Inc., hibernate.generate_statistics=false, java.runtime.version=1.6.0_06-b02, hibernate.connection.autocommit=true, user.name=Haim, shared.loader=, tomcat.util.buf.StringCache.byte.enabled=true, hibernate.connection.release_mode=auto, user.language=iw, java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory, sun.boot.library.path=C:\Program Files\Java\jre1.6.0_06\bin, java.version=1.6.0_06, user.timezone=Asia/Jerusalem, sun.arch.data.model=32, java.endorsed.dirs=C:\ADC\apache-tomcat-6.0.24\endorsed, sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86, sun.jnu.encoding=Cp1255, file.encoding.pkg=sun.io, package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans., file.separator=\, java.specification.name=Java Platform API Specification, java.class.version=50.0, user.country=IL, java.home=C:\Program Files\Java\jre1.6.0_06, java.vm.info=mixed mode, os.version=6.0, hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory, hibernate.query.jpaql_strict_compliance=true, path.separator=;, java.vm.version=10.0-b22, hibernate.connection.password=, user.variant=, java.awt.printerjob=sun.awt.windows.WPrinterJob, sun.io.unicode.encoding=UnicodeLittle, awt.toolkit=sun.awt.windows.WToolkit, hibernate.connection.username=root, package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper., java.naming.factory.url.pkgs=org.apache.naming, user.home=C:\Users\Haim, java.specification.vendor=Sun Microsystems Inc., hibernate.hbm2ddl.auto=update, java.library.path=C:\Program Files\Java\jre1.6.0_06\bin;.;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;c:\Program Files\ActivIdentity\ActivClient\;c:\Program Files\Common Files\Roxio Shared\DLLShared\;c:\Program Files\Common Files\Roxio Shared\10.0\DLLShared\, java.vendor.url=http://java.sun.com/, hibernate.connection.driver_class=com.mysql.jdbc.Driver, java.vm.vendor=Sun Microsystems Inc., hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect, common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar, java.runtime.name=Java(TM) SE Runtime Environment, java.class.path=C:\ADC\apache-tomcat-6.0.24\bin\bootstrap.jar, hibernate.bytecode.use_reflection_optimizer=false, hibernate.connection.autoReconnect=true, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0, catalina.home=C:\ADC\apache-tomcat-6.0.24, sun.cpu.endian=little, sun.os.patch.level=Service Pack 2, java.io.tmpdir=C:\Users\Haim\AppData\Local\Temp\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, server.loader=, hibernate.query.factory_class=org.hibernate.hql.classic.ClassicQueryTranslatorFactory, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, os.arch=x86, java.ext.dirs=C:\Program Files\Java\jre1.6.0_06\lib\ext;C:\windows\Sun\Java\lib\ext, user.dir=C:\eclipse-jee-ganymede-SR2-win32\eclipse, hibernate.use_sql_comments=true, line.separator= , java.vm.name=Java HotSpot(TM) Client VM, wtp.deploy=C:\ADC\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps, file.encoding=Cp1255, hibernate.use_identifier_rollback=false, java.specification.version=1.6, hibernate.connection.pool_size=6, hibernate.show_sql=true} Initial EntityManagerFactory creation failed.javax.persistence.PersistenceException: [PersistenceUnit: profound_db] Unable to build EntityManagerFactory
|