What is this spring.jpa.open-in-view=true property in Spring Boot?

I saw spring.jpa.open-in-view=true property in Spring Boot documentation for JPA configuration. Is the true default value for this property if it’s not provided at all?; What does this really do? I did not find any good explaining for it; Does it make you use SessionFactory instead of EntityManagerFactory? If yes, how can I tell it … Read more

Spring Boot – Cannot determine embedded database driver class for database type NONE

This is the error that is thrown when trying to run my web app: [INFO] WARNING: Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource’ defined in class path … Read more

How to map a composite key with JPA and Hibernate?

In this code, how to generate a Java class for the composite key (how to composite key in hibernate): create table Time ( levelStation int(15) not null, src varchar(100) not null, dst varchar(100) not null, distance int(15) not null, price int(15) not null, confPathID int(15) not null, constraint ConfPath_fk foreign key(confPathID) references ConfPath(confPathID), primary key … Read more

How does spring.jpa.hibernate.ddl-auto property exactly work in Spring?

I was working on my Spring boot app project and noticed that, sometimes there is a connection time out error to my Database on another server(SQL Server). This happens specially when I try to do some script migration with FlyWay but it works after several tries. Then I noticed that I didn’t specify spring.jpa.hibernate.ddl-auto in … Read more

Spring CrudRepository findByInventoryIds(List inventoryIdList) – equivalent to IN clause

In Spring CrudRepository, do we have support for “IN clause” for a field? ie something similar to the following? findByInventoryIds(List<Long> inventoryIdList) If such support is not available, what elegant options can be considered? Firing queries for each id may not be optimal. 3 Answers 3

Hibernate throws org.hibernate.AnnotationException: No identifier specified for entity: com..domain.idea.MAE_MFEView

Why am I getting this exception? package com.domain.idea; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; import org.hibernate.annotations.AccessType; /** * object model for the view [InvestmentReturn].[vMAE_MFE] */ @Entity @Table(name=”vMAE_MFE”, schema=”InvestmentReturn”) @AccessType(“field”) public class MAE_MFEView { /** * trade property is a SuggestdTradeRecommendation object */ @OneToOne(fetch = FetchType.LAZY , cascade = { … Read more

Confusion: @NotNull vs. @Column(nullable = false) with JPA and Hibernate

When they appear on a field/getter of an @Entity, what is the difference between them? (I persist the Entity through Hibernate). What framework and/or specification each one of them belongs to? @NotNull is located within javax.validation.constraints. In the javax.validation.constraints.NotNull javadoc it says The annotated element must not be null but it does not speak of … Read more

What is the meaning of the CascadeType.ALL for a @ManyToOne JPA association

I think I misunderstood the meaning of cascading in the context of a @ManyToOne relationship. The case: public class User { @OneToMany(fetch = FetchType.EAGER) protected Set<Address> userAddresses; } public class Address { @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) protected User addressOwner; } What is the meaning of the cascade = CascadeType.ALL? For example, if I … Read more