Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [jpa]

The Java Persistence API (JPA) is a specification that describes the management of relational data in Java applications.

3
votes
1answer
70 views

Inserting 50k rows with Spring Data and JPA [closed]

I am using Spring Data JPA with Spring boot application. My requirement is to insert 50K rows in JPA entity table in one hour or less. I have 3 entities A, B and C. Entity A has a one to many ...
2
votes
2answers
119 views

JPA method to update roles for users

In my Spring MVC app I have User and Role entities. User: ...
3
votes
0answers
77 views

Enclosing JPA Boilerplate Code

This is an attempt to create interfaces holding the boilerplate code of basic JPA interactions. Code in question/review JPAInteraction.java ...
-1
votes
1answer
601 views

How to avoid duplicate code due to the impossibility of using multiple inheritance

I'm working on a Spring - Hibernate App, and I have a question about how to correctly avoid duplicate code and using Hibernate, due to the impossibility of using use multiple inheritance (I usually ...
4
votes
2answers
8k views

Inserting 100000 records to MySQL takes too much time

I'm using spring boot, hibernate any MySQL for reading 100000 records from csv file and write the same to the database. I'm doing the batch insert where the data is committed at intervals equal to ...
1
vote
2answers
145 views

Check repository for a nested entity

I have a Product entity and a ProductCategory entity. Given the Product entity, my ...
2
votes
0answers
117 views

REST web service to interface with a customer database

In what ways could I improve this? Does it look good? Any security concerns? I am using Jersey, Jackson and JPA. What about the architecture? I basically have ...
-1
votes
1answer
91 views

Accepting any object and returning the object

I have been tinkering with generic methods in Java but still haven't figured out a way to optimize this code. Here I need to write similar piece of code for both plan and add-on. ...
1
vote
0answers
446 views

CRUD in Managed Bean

I want know what are best practices for CRUD operations in Managed Bean. I created EntityManagerUtils class which contains CRUD methods and redirect value to ...
5
votes
2answers
3k views

Generic toString() for JPA base entity class

In a Java/JPA project I usually define a base class (on which I put the id). The goal is to implement an generic toString() on this base class (named BaseEntity) from which all other entities inherit. ...
5
votes
1answer
83 views

Listing Books nicely - a tour through a webapp

In this exercise, I do not want to use any container such as Spring or Glassfish. I am deploying my application to Tomcat. I only use JPA. What I want to achieve is to follow best practices and OOP ...
4
votes
1answer
73 views

Filtering JPA search results for comment threads by votes

I've concerns about the code below because I'm getting a lot of unnecessary data from my DB and I delete it afterward to only have the "good" data. I didn't find any good workaround to get the data ...
2
votes
1answer
386 views

Hibernate entity design with a Currency class

I have a class Currency, where I want to store business logic for working with currencies: ...
4
votes
1answer
1k views

Property Change Listener for Entity Management

I would like to know if the solution I came up with for managing relationships between entities is sensible. Guys in my team feel it is transparent, but maybe I'm missing a pitfall somewhere? ...
8
votes
2answers
738 views

Shortening JPA criteria query boilerplate

I've used hibernate for a long time. Recently I started using JPA, but I can't find a short way to write a simple select in less than these seven lines (the use of criteria is a must in this project). ...
2
votes
1answer
7k views

JavaEE 7 with JPA (Hibernate) and JAX-RS (RestEasy)

below is a working example of code in which you can create car colors and cars using these colors with XML POST messages. And request all cars and colors formatted in XML using a GET message. I am ...
1
vote
1answer
2k views

Simple guestbook made using Java EE 7

I'm making my first steps in Java EE. This is a simple guestbook made using Java EE 7 technologies (JSF, CDI, EJB, JPA). Does the code follows the standard best practices? Is there a possibility for ...
0
votes
1answer
101 views

Facade pattern usage with JDBC-resource on Glassfish

For this project: ...
4
votes
2answers
179 views

Making a database entity superclass

I am using JPA for my database work and I need to create a database entity superclass which all of my table entities will extend. Every database entity will have a primary key named ...
0
votes
1answer
148 views

First facelets with JPA app on glassfish

So far as I've tested it, these few facelets files with JPA database connections work as intended. The queue, MyQueue, is at ...
1
vote
1answer
1k views

JavaSE client: is this how to get a new JPA EntityManager each time? (DAO)

This class functions, in that the program can be left open for hours and it will still reconnect to the database when the user prompts for a CRUD operation. I've read about DAO, and some other ...
4
votes
1answer
9k views

Inserting data in 3 tables of a database with JPA

I am starting a personal project and my first step is to insert a lot of statuses from tweeter in a database along with it's user and place (if applicable). This is the database structure: Pretty ...
7
votes
1answer
67 views

Intern AuditSystem in DB and getting users from it

My project has a change on the database, so that every INSERT-UPDATE-DELETE action is logged with triggers on the DB. For that they have an extra table created: Table ...
3
votes
3answers
20k views

Efficient way of handling multiple sorting and filtering using JPA

I'm using JPA 2.0, Mojarra 2.1.9 and its component library Primefaces 3.5. I have a table in MySQL database named state_table with three columns. state_id (BigInt) ...
1
vote
2answers
174 views

Repetitive code for different Database Entities with same implementation

I have this code in LogInService ...
4
votes
1answer
2k views

JPA connection : is this code is efficient enough

By reading some tutorial i have written some peace of code to do crud operation . I just want to know how is this code is efficient or how can i make better ? Here i am giving code of 3 class 1. ...
5
votes
2answers
2k views

Checking if entity exist in Google App Engine Datastore using JPA 1

Below is my method in checking if entity already exist. ...