Questions tagged as 'jpa'

1
answer

Hibernate / JPA - object is an unsaved transient instance

Good afternoon people! When saving a new contract readjustment I have to search for other "similar" contracts to what I'm re-adjusting and readjust them as well. So I was trying to use a callback ( saveAfter ) after saving the first...
asked by 14.11.2016 / 15:41
1
answer

Remove default message @Pattern JPA

I need a help from you. I'm creating a web service rest in java using jersey and hibernate. To validate the fields reported by the caller I used the JPA @Pattern annotation, as follows: @XmlRootElement public class Cfop { @Pattern(regexp = "[...
asked by 09.11.2016 / 22:12
2
answers

How to return the number of entities in a table using JPA and the COUNT function?

I'm using the EclipseLink implementation and I can not resolve the following query that should be wrong: Query query = em.createQuery("SELECT e , COUNT(*) FROM Empregado e"); Integer resultado = (Integer) query.getSingleResult(); M...
asked by 10.08.2016 / 19:21
1
answer

Multiples @ElementCollection in two different classes @Embeddable

I have an entity with two Embedded classes of the same type, and each has an ElementCollection of the same type, too. The business logic seems to be correct, but I'm experiencing some problems with the lack of knowledge in JPA. Here are m...
asked by 18.08.2016 / 19:09
1
answer

Problem with connection control with the Bank

I'm having some connection problems with the database. Here is my code and the exception. Code @Repository public class MinhaClasseDAOImpl implements MinhaClasseDAO{ protected EntityManagerFactory entityManagerFactory = Persistence.creat...
asked by 11.07.2016 / 15:27
1
answer

Sensitive data in persistence.xml

I'm using JPA in my application and so I have a persistence.xml file that contains the connection data with my database: <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost/banco" /> <property name="j...
asked by 28.08.2016 / 18:05
1
answer

Error: EntityManager is closed

My command system, when trying to merge tables, I use EntityManager.merge, however the following error occurs: EntityManager is closed. Here is one of the functions in my code that causes this error: public boolean trocar_Mesa(BigDecimal or...
asked by 05.07.2016 / 02:40
1
answer

Query in JPQL for insertion of Data

How can I insert data with JPQL containing values: @Query("insert into user values()") User insertUser(); Data:     username     emailUser     
asked by 16.08.2016 / 17:40
1
answer

Jasper Studio with Hibernate Session

I'm trying to add a connection in Jasper Studio via the "Hibernate Session" option I've added the Hibernate .jars, the MySQL Driver and set the hibernate.cfg.xml file, but I still have the access: Caused by: java.sql.SQLException: No suitable...
asked by 30.06.2016 / 20:23
1
answer

Using CDI in the app

I have a problem, on my login screen I can inject the em into a good one, when I go to the second screen that would be dash, I can not inject, p> Follow the link: /* * To change this license header, choose License Headers in Project Pro...
asked by 18.05.2016 / 21:16