hibernate-4.x

How to use SchemaExportTool with JPA and Hibernate 4.3

爷,独闯天下 提交于 2019-12-01 21:21:38
问题 At Hibernate 4.3 Ejb3Configuration class was removed. This class was commonly used for creating hibernate configuration file from a persistence unit (persistence.xml file) to SchemaExport tool. As a simple alternative to export schema to .sql file I'm using the following code: public static void export(String persistenceUnit, String exportFileName) { Map<String, String> hash = new HashMap<String, String>(); hash.put("hibernate.hbm2ddl.auto", "create-drop"); EntityManagerFactory factory =

How to use SchemaExportTool with JPA and Hibernate 4.3

纵然是瞬间 提交于 2019-12-01 18:28:11
At Hibernate 4.3 Ejb3Configuration class was removed. This class was commonly used for creating hibernate configuration file from a persistence unit (persistence.xml file) to SchemaExport tool. As a simple alternative to export schema to .sql file I'm using the following code: public static void export(String persistenceUnit, String exportFileName) { Map<String, String> hash = new HashMap<String, String>(); hash.put("hibernate.hbm2ddl.auto", "create-drop"); EntityManagerFactory factory = Persistence.createEntityManagerFactory( persistenceUnit, hash); org.hibernate.jpa.internal

“Error creating bean with name” When creating a Transaction Manager

断了今生、忘了曾经 提交于 2019-12-01 18:23:20
Here is my hibernate.cfg.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- Database connection settings --> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/sometable</property> <property name="connection.username">root</property> <property name="connection.password">somepassword</property> <!-- JDBC connection

hibernate 4.3.x - load all entity annotated classes

久未见 提交于 2019-12-01 17:25:17
In a project which I work on I don't use Spring, I use Hibernate only. I don't want to use hbm.xml files for entity mappings/descriptions/etc. I want to use annotations only. How do I tell Hibernate to load all Entity/Table annotated classes from certain package(s)? I searched on the web but I have no luck. Also I don't find information about the latest Hibernate version (mostly outdated articles/posts/etc.). Edit 1: http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html_single/#mapping The hibernate doc page says this: Object/relational mappings can be defined in three approaches: 1) using

Hibernate 4 explicit polymorphism (annotation) not working?

天涯浪子 提交于 2019-12-01 17:07:11
I am facing problem with hibernate's explicit polymorphism. I used the polymorphism annotation and set it to explicit, but with get() and collections in mapped classes i always get all subclasses. I see all subclasses with left join in the hibernate "show_sql" output. What's the problem? Do I understand the documentation wrong? Or is it a bug in hibernate 4? I haven't seen any example with hibernate 4 and polymorphism annotation. sessionFactory.getCurrentSession().get(Node.class, 111); // return subclasses! @Entity @Table(name="Nodes") @Inheritance(strategy = InheritanceType.JOINED)

Hibernate4 on JBoss EAP 5.1.2 logging error

空扰寡人 提交于 2019-12-01 04:28:38
I'm hoping that maybe someone has run into this problem before and can provide advice. I'm writing an application on Hibernate 4 and Spring 3. Here's my dependency tree: +- javax.servlet:servlet-api:jar:2.5:provided +- org.springframework:spring-webmvc:jar:3.1.3.RELEASE:compile | +- org.springframework:spring-asm:jar:3.1.3.RELEASE:compile | +- org.springframework:spring-beans:jar:3.1.3.RELEASE:compile | +- org.springframework:spring-context:jar:3.1.3.RELEASE:compile | +- org.springframework:spring-context-support:jar:3.1.3.RELEASE:compile | +- org.springframework:spring-core:jar:3.1.3.RELEASE

Replacement for org.hibernate.Transactions.isActive() in Hibernate 5

自闭症网瘾萝莉.ら 提交于 2019-12-01 03:44:09
问题 I'm migrating from hibernate 4.2.17 to 5.0.7 which works fine so far, but it seems that the method isActive is deprecated. I just can't use it anymore. Here's my code: public void starteTransaktion() { try { getMySession(); if(!hibernateSession.getTransaction().isActive()) { hibernateSession.beginTransaction(); } } catch (HibernateException e) { } } I substituted all other methods, but I can't quite find a replacement for this... Error message: The method isActive() is undefined for the type

How do I get unit test to run in java 7: java.lang.VerifyError: Expecting a stackmap frame at branch target

ⅰ亾dé卋堺 提交于 2019-12-01 02:54:47
Hi I am running a maven test using maven 3.0.3 with hibernate 4.0.0 Final release and spring 3.1 on jdk7 update 2. I get the following error. Caused by: java.lang.VerifyError: Expecting a stackmap frame at branch target 63 in method ${myDomainClass}.equals(Ljava/lang/Object;)Z at offset 24 at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2442) at java.lang.Class.getDeclaredMethods(Class.java:1808) at org.hibernate.property.BasicPropertyAccessor.getterMethod(BasicPropertyAccessor.java:352) at org.hibernate.property

How to configure second level cache in Hibernate 4.1.5 SP1?

一个人想着一个人 提交于 2019-11-30 15:41:28
问题 I have read other threads on here about this subject but none of the solutions work for me. I tried putting this in my hibernate.cfg.xml: <property name="hibernate.cache.region.factory_class">org.hibernate.cache.spi.EntityRegion</property> I always get this error: could not instantiate RegionFactory [org.hibernate.cache.spi.EntityRegion] I also tried most suggestions from threads on Hibernate websites but no luck. So how do I configure this? 回答1: Well, I found the answer (from a Youtube user)

How to configure second level cache in Hibernate 4.1.5 SP1?

柔情痞子 提交于 2019-11-30 14:38:18
I have read other threads on here about this subject but none of the solutions work for me. I tried putting this in my hibernate.cfg.xml: <property name="hibernate.cache.region.factory_class">org.hibernate.cache.spi.EntityRegion</property> I always get this error: could not instantiate RegionFactory [org.hibernate.cache.spi.EntityRegion] I also tried most suggestions from threads on Hibernate websites but no luck. So how do I configure this? MrStack Well, I found the answer (from a Youtube user): Use hibernate-release-4.1.0.Final or later versions. Add jars from lib\optional\ehcache directory