hibernate

NullPointerException while trying to add an orm layer using hibernate

给你一囗甜甜゛ 提交于 2021-02-10 15:14:00
问题 Well,I have been trying to add an orm layer for past 3 weeks and i havent been able to do so.I was trying to learn from the tutorial.I have done whatever the tutorial says .Here is the code Student.java package com.codinghazard.actions; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name="student") public class Student { @Id @GeneratedValue private int id;

User defined PostgreSQL function in hibernate dialect throws exception

蓝咒 提交于 2021-02-10 15:10:33
问题 Is it possible to register a custom function written in database & written in extended hibernate Postgres Dialect as follows? Receiving function not exists exception on using this function in HQL. Postgres function: create or replace function ADD_DAYS(varDate timestamp without time zone, varNumber numeric) returns timestamp without time zone LANGUAGE sql AS $$ SELECT (varDate + varNumber * INTERVAL '1 day') $$; Java code: registerFunction("add_days", new SQLFunctionTemplate(StandardBasicTypes

Hibernate 5 Java bidirectional oneToMany field is null but table contains data

允我心安 提交于 2021-02-10 14:51:55
问题 I have two entities Department and Employee. Department has a list of Employees. And Employee has a field Department. I can create Employees and add them to to list inside Department. The Database Tables are filled as expected on persist. If I query for a Department I get the Department and the List of Employees is filled. Everything fine this way. If I query for an Employee and get the Department field it Returns null. @Entity @Table(name = "DEPARTMENT") public class Department { @Id

Hibernate query to filter results from a nested object list

戏子无情 提交于 2021-02-10 14:14:52
问题 As a followup to this answer(on approach 1 ) I want to go a step further : I want to Filter the grand child objects based on certain criteria's. I tried the following query, but it still does not filter out the objects under the grandchild entity. @Query("select ch from ChildEntity ch " + " join ch.parentEntity pr " + " join fetch ch.grandChildEntities gc " + " where pr.bumId = :bumId and ch.lastExecutionTimestamp in " + "( select max(ch1.lastExecutionTimestamp) from ChildEntity ch1 " + "join

Spring boot with H2 Database auto create

假装没事ソ 提交于 2021-02-10 12:43:03
问题 I am using embeded H2 in my java application via spring boot. Currently, it creates(overrides) my tables in the DB. But once I push it to production I do not want my tables to be wiped off and recreated, so I wont lose the previous datas in the tables. But I am not sure how to accomplish this. Not sure what to put on the line spring.jpa.hibernate.ddl-auto=create . I tried validate and other options but did not work out. Here is my application.properties. Thanks spring.jpa.generate-ddl=true

Spring boot with H2 Database auto create

余生颓废 提交于 2021-02-10 12:42:35
问题 I am using embeded H2 in my java application via spring boot. Currently, it creates(overrides) my tables in the DB. But once I push it to production I do not want my tables to be wiped off and recreated, so I wont lose the previous datas in the tables. But I am not sure how to accomplish this. Not sure what to put on the line spring.jpa.hibernate.ddl-auto=create . I tried validate and other options but did not work out. Here is my application.properties. Thanks spring.jpa.generate-ddl=true

Error executing DDL "create table in Spring Data JPA?

淺唱寂寞╮ 提交于 2021-02-10 12:18:42
问题 I want to save some data coming from the request. for that, I created some entity classes. but why I et this exception? Error executing DDL "create table body_datum (body_datum_id integer not null, key varchar(255), value varchar(255), value_type varchar(255), primary key (body_datum_id)) engine=InnoDB" via Here are my properties. spring.datasource.url= jdbc:mysql://localhost:3306/loadtestdb?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

Error executing DDL "create table in Spring Data JPA?

ぐ巨炮叔叔 提交于 2021-02-10 12:15:41
问题 I want to save some data coming from the request. for that, I created some entity classes. but why I et this exception? Error executing DDL "create table body_datum (body_datum_id integer not null, key varchar(255), value varchar(255), value_type varchar(255), primary key (body_datum_id)) engine=InnoDB" via Here are my properties. spring.datasource.url= jdbc:mysql://localhost:3306/loadtestdb?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

Hibernate 5 - java.lang.NoSuchMethodError: javax.persistence.Table.indexes()

别来无恙 提交于 2021-02-10 12:04:41
问题 I'm trying to test some POJOs with hibernate annotations and I'm getting the same error on and on. I used the same configuration in another project and it all worked fine. I tested the jdbc connection that is used when the hib objects are tested - and the connction works fine. I have found a few other questions asked about the same error but nothing was helpful. The code in testing class with main method: public static void main(String[] args) { SessionFactory factory = new Configuration()

JPA does not insert new childs from one to many relationship when we use merge

邮差的信 提交于 2021-02-10 10:54:32
问题 My question is pretty similar to the following: JPA: How do I add new Items to a List with a OneToMany annotation Why merging is not cascaded on a one to many relationship JPA with JTA: Persist entity and merge cascaded child entities I also had a look in Wikibooks but still not able to fix my problem So, my problem is that I have a Parent class with childs, and when I add a new child and use entityManager.merge(parent) to update the new children are not inserted and I get an error of null