Solve Hibernate Lazy-Init issue with hibernate.enable_lazy_load_no_trans

The problem with this approach is that you can have the N+1 effect. Imagine that you have the following entity: public class Person{ @OneToMany // default to lazy private List<Order> orderList; } If you have a report that returns 10K of persons, and if in this report you execute the code person.getOrderList() the JPA/Hibernate will … Read more

Making data persistent in android

Many applications may provide a way to capture user preferences on the settings of a specific application or an activity. For supporting this, Android provides a simple set of APIs. Preferences are typically name value pairs. They can be stored as “Shared Preferences” across various activities in an application (note currently it cannot be shared … Read more

Why can’t environmental variables set in python persist?

You can’t do it from python, but some clever bash tricks can do something similar. The basic reasoning is this: environment variables exist in a per-process memory space. When a new process is created with fork() it inherits its parent’s environment variables. When you set an environment variable in your shell (e.g. bash) like this: … Read more

Refresh and fetch an entity after save (JPA/Spring Data/Hibernate)

Instead of defining EntityManager in each of your resource, you can define it once by creating a Custom JpaRepository. Reference Then use the refresh of your EntityManager in each of your repository directly. Refer the below example: CustomRepository Interface import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.repository.NoRepositoryBean; import java.io.Serializable; @NoRepositoryBean public interface CustomRepository<T, ID extends Serializable> extends JpaRepository<T, ID> … Read more

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