All Questions
Tagged with jpa entitymanager
905
questions
1
vote
1
answer
109
views
Spring Data JPA/Hibernate: JPQL constructor expressions- difference between using "new(..)" and not using it
I am using JPQL and projecting the specific returned fields into a different Class than the Entity. I can achieve it using at least the following 2 ways in JPQL with EntityManger (em in code):-
@Test
...
0
votes
1
answer
47
views
Getting exception "detached entity passed to persist"
I am trying to delete a old child entities, create new child entities, update grandparent entity using Entity Manager using a single transaction. Below are my code:
Entity Classes
@Data
@Entity
@...
0
votes
1
answer
50
views
Getting "java.lang.IllegalArgumentException : Removing a detached instance"
I am trying to delete a old child entities, create new child entities, update grandparent entity using Entity Manager using a single transaction. Below are my code:
Entity Classes
@Data
@Entity
@...
0
votes
2
answers
48
views
Unexpected behavior with EntityManager and the Persistence Context
I am currently trying to learn both JPA and Hibernate and I've been playing around with some dummy code to understand how everything works. However, I've come up with an example that I don't quite ...
1
vote
1
answer
46
views
How to manage transaction when testing JPA application
I have a server application which interacts with a database via JPA. Methods in this application usually look like this:
entityManager.getTransaction().begin();
try {
// do some work
entityManager....
0
votes
0
answers
47
views
Persist a java object with EntityManager
I am trying to save an object to my database using Entity Manager in my Tomcat application but I am having some trouble with getting it to work because my DAO instance is null.
This is my code
User....
0
votes
2
answers
59
views
Transactional annotation is not working in pure Spring with EntitManager
I have a simple bookdao class:
@Repository
public class BookDao {
@Autowired
private EntityManager entityManager;
@Transactional
public void create(Book book) {
entityManager....
0
votes
0
answers
94
views
How to register dynamic JPA entities and repositories before Spring context loads using ByteBuddy?
I am attempting to dynamically create a JPA entity and its corresponding repository using ByteBuddy before the Spring context is fully loaded. My goal is to use the dynamically generated entity and ...
1
vote
2
answers
68
views
java transaction.rollback() not rollbacking the DB
I try to do transactions on my project java, and I realise all transactions don't rollback the rows in DB.
It's a local project (the DB was MySQL on phpmyadmin, all tables in innoDB).
I try to do an ...
0
votes
0
answers
18
views
Spring JPA entity doesn't update when i use getReferenceId() in transactional function
The contents of the database do not change despite the normal communication and modification of the contents to be modified through the DTO.
entity code like this
@Getter
@ToString(callSuper = true)
@...
0
votes
0
answers
105
views
How can I get the column name when using native query?
I am creating a function that receives a select query statement from a client, processes it, and queries it. However, when returning json data, I would like to not only return the query value in a ...
0
votes
1
answer
55
views
Is calling method of EntityManager in a container-managed transaction context inside Servlet thread-safe?
There is the following code snippet inside a servlet
@PeristenceContext
private EntityManager entityManager;
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
...
0
votes
0
answers
19
views
EntityManager.find() SQL Injection safe
Is the EntityManager.find() SQL injection safe?
I have this codes and Checkmarx complaining on SQL Injection.
`public T find(ID id) {
return entityManager.find(persistentClass, id);
}`
...
0
votes
0
answers
67
views
JPA and Hibernate - Select same object twice and get two instances
I am using spring boot version 3.1.6 with appropiate jpa and hibernate dependencies.
And now I try the following:
Select a (tree-like) Object that can get pretty large
Execute a complex data ...
0
votes
0
answers
67
views
org.hibernate.PersistentObjectException: detached entity passed to persist inside CompletableFuture.runAsync()
Hey can anyone help me in this, Getting a weird error.
I have two Entities:
@Entity
@Table(name="dbdetails")
public class DBdetails {
@Id
@GeneratedValue(strategy= GenerationType....