Questions tagged [hibernate]

An object-relational mapping (ORM) framework for the Java programming language.

Filter by
Sorted by
Tagged with
0
votes
1answer
19 views

Jpa Repository save inside a for loop

I have this requirement: Csv Upload (using opencsv) Should display if the record is inserted (if it doesn't exist in the db) or updated (if it exists). Eg.: 5 records inserted 2 records updated. ...
2
votes
1answer
71 views

Can I reduce locking for this scenario using Hibernate and H2

My Java application uses Hibernate and H2. It process music files within folders. Typically for a folder it would read the files in the folder and store each file as a Song class in database, then ...
2
votes
2answers
74 views

Query with a lot of fields and joins

I have to map a legacy database with tables that have a lot of fields and relations. For example (simplified code), @Entity @Table(name = "VISIT") public class VisitEntity { @Id private ...
0
votes
1answer
83 views

DDD persistence through non-orm tools in java

So our domain model drove our database and ORMs worked for DDD implementations. Now the tables have been altered a lot and as a consequence ORM impedence is too much in our domain model to use ...
1
vote
0answers
24 views

DataBase design generated by hibernate Many to Many for MariaDB

Hi I am in middle of designing DB and Got a little bit confused about DB Design. I am Using Hibernate as ORM Tool ahd mapping between Page and Step entity in hibernate. @ManyToMany(fetch = FetchType....
1
vote
1answer
68 views

concept for de- and encrypting personal data in web portal

Issue: I provide a small web portal for customers with partial personal data like name, address etc. which is stored in the database in plain text. Now I need a safe concept to encrypt the personal ...
0
votes
1answer
53 views

Add the database layer to your application with a service or include it directly?

I am planning to set up a new Web-application that contains the following things: I want to use JavaEE with JSF for the Frontend & Backend combined with git-hooks to deploy them onto my server. ...
0
votes
0answers
60 views

Edit List attribute in JPA when null?

I am using EclipseLink as my JPA implementation and Postgresql as my DB. JPA: @Struct(name="label,.....") @Entity @Table(name="\"XYZ\"", schema="\"XYZ\"") @NamedQuery(name="...
0
votes
1answer
38 views

Best way to handle environment specif fields in Hibernate

We have one microservice that will be deployed on two different environments(A and B). There are some common fields and also some are specific to the environment. Example: SomeEntity for environment ...
0
votes
1answer
401 views

In new project where you have ability to define DB and write app code, what is seen as best practice?

Good day When starting a new project and you have access to the db as well as writing the code. In this specific case it is PostgreSQL and Java EE with JPA and Hibernate. Should one: Aim to ...
0
votes
0answers
2k views

Repository vs. DAO (again)

In general this back-story does not matter but just to explain the code below: The server handles users and user groups. User groups are able to "discover" places - at this point in time these places ...
1
vote
2answers
378 views

Optimal use of hibernate with mysql's stored procedures

I am working on a project (to use as a reference). The project uses mysql, hibernate and spring (REST) and is supposed to be a single microservice. I have come to find out that limiting user/consumer ...
-2
votes
1answer
89 views

Is generating Hibernate Entities from database tables considered a bad practices?

On my current project it is a common practice to generate Hibernate Entities from database tables using NetBeans functionality. I'm normally used to first write the Entity-class and define the mapping ...
1
vote
0answers
2k views

Using import.sql vs persisting JPA entities

In Hibernate ORM & Spring Boot, during the SessionFactory creation, SQL DML statements can be executed to create tables and/or insert data via files such as import.sql defined in the javax....
0
votes
1answer
2k views

How to represent and validate website URLs for a JPA entity

I have an application that will allow the user to enter and store (in a DB) a website URL for a company. The only requirement (as of now) beyond entry of the website URL is to validate that the URL is ...
0
votes
4answers
1k views

Best way to track user changes

I'm developing a webapp with users and roles, and I need to keep track of any changes that are made, so that I know when and who has changed a user role. I have my user table: CREATE TABLE user( ...
2
votes
1answer
93 views

Reattachment of full entity graphs for frontend/backend applications which communicates using REST API/JSON?

I am trying to develop business application with separated backend (persistence, business logic, server side workflows) and frontend (presentation, some business logic) which communicates using REST ...
1
vote
1answer
378 views

Does separating Domain model and Persistence model have impact on transactional aspect?

In this post, there is: For example, with your own persistence model, you are not able to benefit from the built-in change tracking functionality. And that means you will not be able to ...
1
vote
1answer
552 views

How to reuse boilerplate code for Hibernate session management?

My Java application uses Hibernate as an ORM framework. I find myself often writing code like this: Session session = HibernateUtil.getSessionFactory().openSession(); try { session....
3
votes
0answers
797 views

Allowing users to add their own custom fields in a Spring MVC Hibernate application - What's an ideal approach?

We all may have seen applications like JIRA, or many CRM or other applications that allow its users to define their own custom fields to an entity, and do a variety of stuff with it, like making them ...
0
votes
1answer
901 views

Decoupled architecure between business and data layers in Spring JPA / Hibernate

I'm using Spring Boot with JPA / Hibernate and I'm trying to decouple the business layer from the data layer. I would like to be able to (relatively easily) switch from a relational database to a rdf ...
1
vote
0answers
405 views

Is BoneCP + JDBC a good alternative to JPA/Hibernate?

To some extent, I don't have a problem with JPA which inevitably needs an implementation such as Hibernate. However, it requires configuration and ORM. I don't specifically like using Hibernate ...
1
vote
1answer
217 views

Modeling complex tree structure

After asking it in stackoverflow : polymorphism-and-tree-structre I came to a conclusion that I am not being specific and my question is not about any specific technology so I will try to rewrite it. ...
6
votes
4answers
1k views

Examples of mid/large-scale web-apps built without an ORM?

I've been reading a lot of hate spewed on ORMs, and am genuinely interested in finding out if there is a better way of doing things. Unfortunately, while there are tons of books, blog posts, and ...
2
votes
2answers
8k views

How do I integrate hibernate and REST web service in java?

I am going to develop which will be web application as well as mobile (android / iOS / windows) application. The database in this application will be managed by Hibernate. Also as it is cross platform ...
4
votes
2answers
3k views

Micro-service database management?

Most people say when building micro-services, that it's best to have separate databases for each of the microservices. E.g: User-microservice: DB - User userId name Etc... Review-microservice: ...
2
votes
1answer
92 views

How to optimize a bloated entity that causes a huge query

I have an application that exposes a series of Web services. One of my entities has a bunch of one-to-many and many-to-many relations to other entities. My transactionality level is at DAO, and I'd ...
3
votes
1answer
742 views

How to paginate local and remote data?

My team is currently facing a problem that we don't know how to tackle. Some technical details: we use Java 8, Hibernate, Spring, MySQL, and AngularJS for the front-end. We need to do pagination on ...
8
votes
5answers
4k views

How to design a complex REST API considering DB performance?

I've been following some tutorials on how to design REST APIs, but I still have some big questions marks. All these tutorials show resources with relatively simple hierarchies, and I would like to ...
5
votes
3answers
16k views

Best way to deal with Hibernate 1->Many relationship over REST/JSON service

Problem: A Hibernate bi-directional One-to-Many relationship does not map easily to JSON. If default (Jackson) mapping is used there is an infinite recursion issue as the parent contains the children ...
2
votes
1answer
841 views

How, in Three Tier Architecture is Database Access Achieved

So I am attempting to make an application based on the architecture proposed by this image; [1] However, I am getting very confused with how data access is achieved between the data access layer ...
5
votes
1answer
1k views

ORM: runtime proxies vs bytecode instrumentation

What are the benefits of using runtime proxies with an ORM provider like Hibernate or EclipseLink compared to bytecode instrumentation/enhancement? I know that bytecode instrumentation helps to ...
1
vote
1answer
1k views

DTO and JPA Version

I have DB tables representing Employees and Departments. The server side(JavaEE) contains JPA entities representing the same. The client is a standalone client and communicates with the server using ...
3
votes
2answers
1k views

What's the correct approach to DAO layer in presence of ORM framework

I'm using JPA/Hibernate but probably it doesn't limit question. Currently I'm writing my data access code in my web controller classes. Thanks to JPA, in most cases this code is very simple, ...
1
vote
3answers
643 views

Limiting complexity in JPA programs Java/Hibernate

I've been working on a new application for some months now. It's my first big JPA program, and is still in the early stages. However, the complexity of my JPA object tree is becoming a growing problem....
6
votes
1answer
1k views

Is this database design good? What JPA Entities should I create for this design?

I am trying my hands on JPA. For this I am thinking of using the example of a student admission process as shown in the diagram below. Is this design good ? Any suggestions for improvement are more ...
7
votes
4answers
6k views

Programmatically extending Hibernate table/entity definitions in Spring, how?

I would like to know if there is a way —maybe with AOP— to extend table/entity definitions so that I can add functionality across the board that requires persistence. Let me explain what I want to do ...
3
votes
1answer
74 views

Dealing with Users and User-Owned Data in an API

I have a question about the way I am architecting an API. Structure My API structure so far is like so (there is about 10 classes total, but many are similar, so I've reduced to these classes, and ...
1
vote
0answers
667 views

Transaction Management in Hibernate with DAO Design Pattern

I have many Tables, For every Table,we have DAO Interface and DAOImplementation class. Example DAO Interface public interface CancelPolicyDAO { public CancelPolicy insertCancelPolicy(CancelPolicy ...
0
votes
1answer
2k views

Logic based on modified fields of a Hibernate entity

I have a Hibernate entity object MyObject with several attributes and a service MyObjectService containing business logic dealing with MyObject. I also have a view model dealing with user input/output ...
0
votes
2answers
520 views

Entity design for a blackjack game - should I make Card an entity?

I am creating a simple blackjack game backed by database In my Card is public class Card{ private Face face; private Suit suit; //setters.. getters } where face and suit are enums I have an ...
15
votes
1answer
7k views

Java application structure: Horizontal vs vertical split

Having a bit of a debate about the starting project structure (using Maven/Eclipse) for a big Java application. Option 1: entities (i.e. the whole database using Hibernate classes-first) services (i....
0
votes
1answer
871 views

Am I doing it wrong with Hibernate DAO layer? i.e. Feature Bloat

For quick prototyping I have been actively using Hibernate. Recently I came back to an old project and I wondered why I had a lot of DAOs with what I suspect is commonly named feature bloat. E.g. I ...
1
vote
2answers
2k views

Using Hibernate Criteria framework for complex queries vs. just making views in DB

I like using Hibernate for regular simple CRUD operations. However, I am trying to understand why anyone would resort to its Criteria framework to assemble complex recordset criteria as opposed to ...
62
votes
6answers
128k views

Service layer vs DAO — Why both?

I have been working with SpringMVC, Hibernate, and some databases in a java web application example. There are a few different ones that do this, but this Spring 3 and hibernate integration tutorial ...
3
votes
1answer
8k views

Java desktop application using MVC + Hibernate

I'm developing a Java desktop application. I'm planning to use MVC architecture described at Oracle site: Java SE Application Design With MVC. I need to store data in database so I decide to use ...
6
votes
4answers
2k views

Performance related doubt in Java with Hibernate

Suppose in some ORM based project (say Hibernate) I am trying to fetch only few columns rather then the whole Object with may be more than 20 attributes. I am writing HQL like "select attr1, attr2 ...
1
vote
1answer
717 views

How to properly use Hibernate

I am new to Hibernate so my question could be seen as a very straight forward one, also I will try not to be too generic (as I am always told off because of that), although as with all architectural ...
2
votes
2answers
175 views

How to handle deleting record with associated records?

This is not a technical question but rather about the right logic on handling delete with foreign key constraint. In my exercise app, I cascaded the record with OneToMany relationship with other ...
3
votes
1answer
125 views

Handling ground-breaking changes in a production system - Insert intermediate level Management object

As our client request, we are proceeding to change the base of our system. We already have the following structure: A class has many students. (simple typical one - to - many) Now we must change ...