criteria api - Hibernate Predicate SelectAll

I'm using Spring Data JPA with a specification to select rows out of table if the user has selected certain filters:public interface Specification { Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder cb);}How do I create a predicate which will return everything?...Read more

hibernate - could not initialize proxy - no Session in @ManyToMany relationship

I have a domain object called User with this property @ManyToMany @JoinTable( name="t_user_fav_hotel", joinColumns=@JoinColumn(name="user_id", referencedColumnName="id"), inverseJoinColumns=@JoinColumn(name="hotel_id", referencedColumnName="id")) private Set<hotel> favoriteHotels = new HashSet<>();I've created a method in the service level to get all the favorites and avoid the error could not initialize proxy and it works fine.userService.getFavorites (loggedInUser());But I don't know how to add a new Ho...Read more

hibernate - Groovy and JPA preventing Spring Boot CrudRepository from doing inserts

I have a (Groovy) Spring Boot app that talks to a H2 in-memory DB (but don't think that matters). I have the following GroceryItem entity:@MappedSuperclassabstract class BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) Long id}@Canonical@TupleConstructor(includeSuperProperties = true)@ToString(includeSuperProperties = true)@Entity(name = 'grocery_items')@AttributeOverrides([ @AttributeOverride(name = "id", column=@Column(name="grocery_item_id"))])class GroceryItem extends BaseEntity { @Column(name = 'groce...Read more

hibernate - Grails: How to use same domain class for 2 different controllers

This is what I'm attempting to do.Form1 -> PCController -> PC -> DatabaseForm2 -> GPCController -> PC -> DatabaseAll the domain classes are mapped to DB During create/edit, Form2 is getting redirected to PCController and the subsequent show/edit page because the created object is of type PC, it's autowired to that controller. <g:link action="show" controller="gPC" resource="${pCInstance}" params="[noheader: params.noheader]"><g:message code="" default="Cancel" /></g:link>I tried switching the pCInstanc...Read more

Hibernate/JPA @AttributeOverrides not playing nicely with Groovy

Please note: full SSCCE and reproducible source code is here on my GitHub repo. Like the README says, just clone and run ./gradlew clean build to reproduce the error that I'm seeing.I'm designing the data model for a Groovy (not Java) Spring Boot app that will use Hibernate/JPA to read/write entities to/from MySQL. All of my entities will extend an abstract BaseEntity which provides a PK as well as another identifier ("refId"). For instance:@Canonical@Entity@MappedSuperclassabstract class BaseEntity { @Id Long id String refId}@Canonical@Enti...Read more

hibernate - GrailsDomainBinder.getMapping(Doamin) is returning null for non persisted domain in Grails-3.2.4

I have Two domains.class ABC{ String xyz static mapping = { discriminator column: 'ABC_TYPE_ID' }}and class XYZ extends ABC{ static mapWith = "none" static mapping = { discriminator value: 3 } }In Grails 2.5.5 below line works perfectly fine but after making the required changes it is not working in Grails-3.2.4 and is giving null.Mapping mapping = new GrailsDomainBinder().getMapping(XYZ) //Works fine Grails 2.5.5Mapping mapping = GrailsDomainBinder.getMapping(XYZ) // Giving null in Grails-3.2.4Please help me i...Read more

hibernate - WildFly exception when L2C enabled

I got this exception in wildfly-8.2 domain mode: Caused by: Unable to acquire lock after [15 seconds] on key [app.entity.UserData#17568183] for requestor [GlobalTransaction::2482:remote]! Lock held by [GlobalTransaction::2135:remote] at org.infinispan.util.concurrent.locks.LockManagerImpl (line 198)Here is the settings: <subsystem xmlns="urn:jboss:domain:infinispan:2.0"> <cache-container name="server" default-cache="default" module="org.wildfly.clustering.server" aliases="singleton cluster"> ...Read more

equals - Hibernate showing non unique object exception during bulk insert of parent entity with Cascade All. Tried all possibilities

I understand that this question has been asked a lot of times on this forum but i believe sometimes there are new kind of issues coming up. This one might be a type. So i have this code with a parent child entity. The relationship between parent to child is one-to-many joined through some column. The Cascade type is ALL(tried with others as well). The generation strategy is sequence which implies Hibernate assigns it at the time of insertion.Now with the insertion of multiple records with id as null, i get this NonUniqueObjectException with Ses...Read more

hibernate - Bitronix with DB2 in spring boot

My configuration works fine if I define a datasource bean with driver properties containing driverType as 4.If I let spring boot auto configuration create the data source bean, data source is created with driver type 2 by default as it's hard coded in the driver. Is creating a bean explicitly the only way?...Read more

How to include Hibernate Javadoc in NetBeans?

In netbeans I was looking for a hibernate javadoc option (the code completion is working properly but I was looking for the description of the functions). I got one JAR file for Hibernate Javadoc : but couldn't find a way to include this and make it work in NetBeans. I included the jar file in the Javadocs option of Java Platform/Library Manager, but that didn't provide any solution. I think there is a Hibernate Javadoc Zip/Folder available which provides the source code/class files and will be appropriate in this...Read more

hibernate - Mapping many-to-many association table with extra column(s)

My database contains 3 tables:User and Service entities have many-to-many relationship and are joined with the SERVICE_USER table as follows:USERS - SERVICE_USER - SERVICESSERVICE_USER table contains additional BLOCKED column.What is the best way to perform such a mapping?These are my Entity classes@Entity@Table(name = "USERS")public class User implements {private String userid;private String email;@Id@Column(name = "USERID", unique = true, nullable = false,)public String getUserid() {return this.userid;}.... some get/set m...Read more

Hibernate Mapping between 3 tables

I need help in entity mapping where 3 tables are involved.table 1: table name: emp:- col 1: Id, col 2: nametable 2:table name: empAddr:- col 1: Id, col 2: empId, col 3: addrIdtable 3:table name: addr:- col 1: Id, col 2: addrLineI have 3 entity classes for each of the above tables.Could anyone help me with the mapping I need to use?emp to empAddr is 1 to manyempAddr to addr is 1 to one...Read more

orm - Hibernate List mapping idx invalid identifier

I'm trying to replace bag mapping with list to avoid multiple bag fetching problem. I checked all the information on Google and find this:<list name="whatEver"> <key column="whatEver_fk"/> <index column="idx"/> <one-to-many class="WhatEver"/></list>But it does not work for me, it always says ."idx" invalid identifier. I followed exactly what's written in document and it also seems a lot ppls can make it work.I also tried to configure bi-directional or uni directional(someone claimed the uni directional wil...Read more

hibernate - Spring transaction : Transaction not active

i develop a app using struts2, spring 3.1, Jpa2 and Hibernate. From Spring i use transactions and, i have an ajax code block that calls for a struts2 action every second (this is happening for every user that is logged into application (simultaneous users are around 20-30 at a time)). this action name is PopupActionpublic class PopupAction extends VActionBase implements ServletRequestAware {private static final long serialVersionUID = -293004532677112584L;private iIntermedService intermedService;private HttpServletRequest servletRequest...Read more

Using JPA/Hibernate in AWS lambda java

I must implement an AWS lambda function in Java that would consume a Kinesis stream and read/write data to a MySQL database. As I already have the model entities defined in another application, I would like to reuse them, and not work with plain SQL/JDBC.So my goal is to implement the lambda using JPA/Hibernate. Is this possible in general? If yes, are there any real examples or best practices?I have previously worked on Spring Boot applications, where similar functionality is perfectly available and easily configurable, and now I don't even kn...Read more