hibernate-5.x

How to configure Grails 3.1.1 to use Hibernate 5

被刻印的时光 ゝ 提交于 2019-11-28 14:13:14
How do I make Grails 3.1.1 user Hibernate 5? The following actions report Hibernate version 4.3.11.Final: In Grails 3.1.1 grails create-app hello311 edit BootStrap.groovy as shown below grails run-app Console shows: Hibernate version is: 4.3.11.Final class BootStrap { def init = { servletContext -> println "Hibernate version is: ${org.hibernate.Version.getVersionString()}" } def destroy = {} } My build.gradle is unedited. The create-app command resulted in the following build.gradle file: buildscript { ext { grailsVersion = project.grailsVersion } repositories { mavenLocal() maven { url "https

Spring Boot Hibernate 5 Ignoring @Table and @Column

徘徊边缘 提交于 2019-11-28 13:28:19
This is driving me mad. I'm implementing Spring Social and it requires you to have a database table named UserConnection (instead of using the standard naming convention of using an underscore to separate the two words). So in my naive world view, I assumed it would be easily solved by specifying @Table(name="UserConnection") ... but no, that would be all too easy. The annotation is ignored and the table is created as user_connection which then causes Spring Social to have a hissy fit. Please tell me there's some easy way to tell my Spring Boot app to just name that one table (and its

Programmatic SchemaExport / SchemaUpdate with Hibernate 5 and Spring 4

不羁岁月 提交于 2019-11-28 09:41:55
With Spring 4 and Hibernate 4, I was able to use Reflection to get the Hibernate Configuration object from the current environment, using this code: @Autowired LocalContainerEntityManagerFactoryBean lcemfb; EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) lcemfb.getNativeEntityManagerFactory(); SessionFactoryImpl sf = emf.getSessionFactory(); SessionFactoryServiceRegistryImpl serviceRegistry = (SessionFactoryServiceRegistryImpl) sf.getServiceRegistry(); Configuration cfg = null; try { Field field = SessionFactoryServiceRegistryImpl.class.getDeclaredField("configuration"); field

Hibernate Migration from 4.3.x to 5.x for method org.hibernate.cfg.Configuration.getClassMapping(className)

爷,独闯天下 提交于 2019-11-27 14:37:08
In Hibernate 4.3.x, there is a method getClassMapping(className) of class org.hibernate.cfg.Configuration . But in Hibernate 5.x, this getClassMapping(className) method is removed from Configuration class. What will be the code substitution in Hibernate-5? Please help on this migration issue. John I posted to Broadleaf Commerce because they also needed PersistentClass : I've been tooling with Hibernate 5, and some of these changes .... To get metadata now use the Serviceloader: package org.broadleafcommerce.openadmin.server.dao; import org.hibernate.boot.SessionFactoryBuilder; import org

spring - hibernate 5 naming strategy configuration

旧时模样 提交于 2019-11-27 08:02:11
I am writing application using postgresql database and spring + hibernate frameworks. I upgraded spring framework from 4.1.5.RELEASE to 4.2.0.RELEASE version and upgraded hibernate framework from 4.3.7.Final to 5.0.0.Final version. After upgrade I have problems with NamingStrategy. In postgresql database, table column names are in lowercase separated by underscore, in application layer, bean properties are in camelcase. This is working spring configuration file for older version: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http:/

Where did Configuration.generateSchemaCreationScript() go in Hibernate 5

只愿长相守 提交于 2019-11-27 07:49:17
In Hibernate 4.x, I used to generate and export the schema as defined in annotated entities as follows (using Spring to find annotated entities on the class path): Connection connection = DriverManager.getConnection("jdbc:h2:mem:jooq-meta-extensions", "sa", ""); Configuration configuration = new Configuration() .setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect"); // [...] adding annotated classes to Configuration here... configuration.generateSchemaCreationScript( Dialect.getDialect(configuration.getProperties())); SchemaExport export = new SchemaExport(configuration,

Hibernate 5 java.lang.NoSuchMethodError org.jboss.logging.Logger.debugf

こ雲淡風輕ζ 提交于 2019-11-27 07:47:13
I have a problem when I deploy a webapp with hibernate 5 Caused by: java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V at org.hibernate.internal.NamedQueryRepository.checkNamedQueries(NamedQueryRepository.java:149) [hibernate-core-5.0.0.CR2.jar:5.0.0.CR2] at org.hibernate.internal.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:759) [hibernate-core-5.0.0.CR2.jar:5.0.0.CR2] at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:490) [hibernate-core-5.0.0.CR2.jar:5.0.0.CR2] at org.hibernate.boot.internal.SessionFactoryBuilderImpl

Spring Boot Hibernate 5 Ignoring @Table and @Column

家住魔仙堡 提交于 2019-11-26 23:36:42
问题 This is driving me mad. I'm implementing Spring Social and it requires you to have a database table named UserConnection (instead of using the standard naming convention of using an underscore to separate the two words). So in my naive world view, I assumed it would be easily solved by specifying @Table(name="UserConnection") ... but no, that would be all too easy. The annotation is ignored and the table is created as user_connection which then causes Spring Social to have a hissy fit. Please

hibernate 5 sequencegenerator not giving the right value

六月ゝ 毕业季﹏ 提交于 2019-11-26 23:21:42
问题 After migrating to Hibernate 5.2.7, I seem to be getting incorrect values for the id field. My code: @Id @SearchableId @GeneratedValue(strategy=GenerationType.AUTO, generator="hms_seq_gen") @SequenceGenerator(name="hms_seq_gen", sequenceName="patregn_seq") protected Integer ID; Hibernate fires this query: select nextval ('patregn_seq') which gives 5367. The last value in the id field in the table is 5358. And I get this ERROR: duplicate key value violates unique constraint

ImprovedNamingStrategy no longer working in Hibernate 5

廉价感情. 提交于 2019-11-26 18:49:24
I have simple spring-jpa configuration where I have configured Hibernate's ImprovedNamingStrategy . This means if my entity class has a variable userName , then Hibernate should convert it to user_name for querying the database. But this naming conversion stopped working after I upgraded to Hibernate 5. I am getting the error: ERROR: Unknown column 'user0_.userName' in 'field list' This is my Hibernate config: @Configuration @EnableJpaRepositories("com.springJpa.repository") @EnableTransactionManagement public class DataConfig { @Bean public DataSource dataSource(){ DriverManagerDataSource ds