Spring Data JPA NamedStoredProcedureQuery Multiple Out Parameters

It looks like @Procedure expects only one OUT parameter which is binded directly to the method return type… To handle multiple OUT params you can use the JPA API directly: StoredProcedureQuery proc = em.createNamedStoredProcedureQuery(“plus1”); proc.setParameter(“arg”, 1); proc.execute(); Integer res1 = (Integer) proc.getOutputParameterValue(“res1”); Integer res2 = (Integer) proc.getOutputParameterValue(“res2”); …

Spring @Transactional(Propagation.NEVER) should create Hibernate session?

The behavior is correct – Hibernate will always create a session (how else would you expect it to perform any operation?), and by loading the entity you have associated it with that session. Since withoutTransaction is not participating in a transaction, the changes made within withTransaction will happen within a new transaction and shouldn’t be … Read more

Persist collection of interface using Hibernate

JPA annotations are not supported on interfaces. From Java Persistence with Hibernate (p.210): Note that the JPA specification doesn’t support any mapping annotation on an interface! This will be resolved in a future version of the specification; when you read this book, it will probably be possible with Hibernate Annotations. A possible solution would be … Read more

Using Oracle XMLType column in hibernate

My Direction and Requirements Entity should store XML as a string (java.lang.String) Database should persist XML in an XDB.XMLType column Allows indexing and more efficient xpath/ExtractValue/xquery type queries Consolidate a dozen or so partial solutions I found over the last week Working Environment Oracle 11g r2 x64 Hibernate 4.1.x Java 1.7.x x64 Windows 7 Pro … Read more

What is package-info.java and how can I add it to my project?

Is used to store javadoc description. You can find it at 7.4.1. Named Packages of the The Java® Language Specification: It is recommended that package-info.java, if it is present, take the place of package.html for javadoc and other similar documentation generation systems. If this file is present, the documentation generation tool should look for the … Read more

JOOQ vs Hibernate [closed]

While jOOQ and Hibernate compete for the same target audience, they do not solve the same problem at all. You’ve already linked this article in your question. The essence of it is simple: Are you going to solve object graph persistence problems? Use an ORM (e.g. Hibernate) Are you going to embed SQL into Java? … Read more

JPA: DELETE WHERE does not delete children and throws an exception

DELETE (and INSERT) do not cascade via relationships in JPQL query. This is clearly spelled in specification: A delete operation only applies to entities of the specified class and its subclasses. It does not cascade to related entities. Luckily persist and removal via entity manager do (when there is cascade attribute defined). What you can … Read more

Total row count for pagination using JPA Criteria API

Thanks Vladimir! I took your idea and used separate count query to use my existing array of predicates in it. Final implementation looks like this: CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<Brand> cQuery = builder.createQuery(Brand.class); Root<Brand> from = cQuery.from(Brand.class); CriteriaQuery<Brand> select = cQuery.select(from); . . //Created many predicates and added to **Predicate[] pArray** . . CriteriaQuery<Long> cq … Read more

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