HikariCP – connection is not available

I managed to fix it finally. The problem is not related to HikariCP. The problem persisted because of some complex methods in REST controllers executing multiple changes in DB through JPA repositories. For some reasons calls to these interfaces resulted in a growing number of “freezed” active connections, exhausting the pool. Either annotating these methods … Read more

query specified join fetching, but the owner of the fetched association was not present in the select list

Use regular join instead of join fetch (by the way, it’s inner by default): String hql = ” select ec.id as entityChangeId, r.id as revisionId from EntityChange as ec ” + ” join ec.revision as r ” + … As error message tells you, join fetch doesn’t make sense here, because it’s a performance hint … Read more

Hibernate problem – “Use of @OneToMany or @ManyToMany targeting an unmapped class”

Your annotations look fine. Here are the things to check: make sure the annotation is javax.persistence.Entity, and not org.hibernate.annotations.Entity. The former makes the entity detectable. The latter is just an addition. if you are manually listing your entities (in persistence.xml, in hibernate.cfg.xml, or when configuring your session factory), then make sure you have also listed … Read more

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

Since the SERVICE_USER table is not a pure join table, but has additional functional fields (blocked), you must map it as an entity, and decompose the many to many association between User and Service into two OneToMany associations : One User has many UserServices, and one Service has many UserServices. You haven’t shown us the … Read more

Another Repeated column in mapping for entity error

The message is clear: you have a repeated column in the mapping. That means you mapped the same database column twice. And indeed, you have: @Column(nullable=false) private Long customerId; and also: @ManyToOne(optional=false) @JoinColumn(name=”customerId”,referencedColumnName=”id_customer”) private Customer customer; (and the same goes for productId/product). You shouldn’t reference other entities by their ID, but by a direct reference … Read more

Kotlin with JPA: default constructor hell

As of Kotlin 1.0.6, the kotlin-noarg compiler plugin generates synthetic default construtors for classes that have been annotated with selected annotations. If you use gradle, applying the kotlin-jpa plugin is enough to generate default constructors for classes annotated with @Entity: buildscript { dependencies { classpath “org.jetbrains.kotlin:kotlin-noarg:$kotlin_version” } } apply plugin: “kotlin-jpa” For Maven: <plugin> <artifactId>kotlin-maven-plugin</artifactId> … Read more

How does JPA orphanRemoval=true differ from the ON DELETE CASCADE DML clause

orphanRemoval has nothing to do with ON DELETE CASCADE. orphanRemoval is an entirely ORM-specific thing. It marks “child” entity to be removed when it’s no longer referenced from the “parent” entity, e.g. when you remove the child entity from the corresponding collection of the parent entity. ON DELETE CASCADE is a database-specific thing, it deletes … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)