Questions tagged [hibernate]

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

Filter by
Sorted by
Tagged with
82 votes
6 answers
159k 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 ...
Jeff's user avatar
  • 1,854
37 votes
5 answers
72k views

What are the advantages of myBatis over Hibernate? [closed]

I've done some research on my own and understand the basic concept. But some insights can only be gained through actual experience. What are the advantages of myBatis that would make it worth ...
Kshitiz Sharma's user avatar
19 votes
1 answer
9k 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....
Steve Chambers's user avatar
19 votes
5 answers
64k views

Do I need to know servlets and JSP to learn spring or hibernate or any other java web frameworks? [closed]

I've been asking a lot of people where to start learning java web development, I already know core java (Threading,Generics,Collections, a little experience with (JDBC)) but I do not know JSPs and ...
KyelJmD's user avatar
  • 971
12 votes
2 answers
15k views

Is Spring + Hibernate prefered instead of EJB 3?

It is my perception that whenever new JEE projects start (where these technologies would be applicable), people prefer to use a combination of Spring + Hibernate instead of EJB 3. It seems junior ...
JohnDoDo's user avatar
  • 2,309
9 votes
5 answers
7k 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 ...
user3748908's user avatar
  • 1,607
9 votes
1 answer
11k views

IntelliJ with Maven compilation

I have a project that needs Hibernate jars. I added them as dependencies in the pom.xml and Maven compiles my project well. However, in the IDE, all annotations and calls to Hibernate API are marked ...
Mik378's user avatar
  • 3,858
8 votes
1 answer
2k 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 ...
Dragan Bozanovic's user avatar
7 votes
4 answers
2k 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 ...
Saurabh Nanda's user avatar
7 votes
3 answers
14k views

How significant are Spring and Hibernate in software development? [closed]

I am a software professional with about 1.6 years of experience in Java. Due to personal reasons, I had to quit my job, and now after 5 to 6 months, I am about start my career again. I am planning to ...
mercurixp's user avatar
7 votes
1 answer
1k views

Why were annotations introduced in Spring and Hibernate?

I would like to know why were annotations introduced in Spring and Hibernate? For earlier versions of both the frameworks book authors were saying that if we keep configuration in xml files then it ...
Chandrashekhar's user avatar
7 votes
3 answers
26k 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 ...
BarrySW19's user avatar
  • 179
7 votes
4 answers
8k 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 ...
dukeofgaming's user avatar
  • 13.9k
6 votes
4 answers
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 ...
Logicalj's user avatar
  • 174
6 votes
3 answers
2k views

When Business Object fields should not exactly reflect database columns

Main advantage with Hibernate annotations is the fact that a simple POJO (also called a Business Object the most of time) can become persistent through Hibernate annotations (or actually JPA) . In ...
Mik378's user avatar
  • 3,858
6 votes
2 answers
1k views

Hibernate set up for beginner

I am learning Hibernate (OR Mapping). I am using Maven for project management. However, I am currently reading a Hibernate book by O'Reilly, and they use ANT for their example. So my question is are ...
James116's user avatar
  • 163
6 votes
1 answer
2k 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 ...
Nils's user avatar
  • 207
5 votes
3 answers
414 views

What reading is recommended for an experienced Java/SQL Developer moving to Apache/Tomcat, Postgres, Hibernate [closed]

I am taking over management and development of a website developed in Java using Hibernate and Postgres, running on Apache/Tomcat. I am an experienced Java developer, and have experience in Ruby on ...
kevin cline's user avatar
  • 33.6k
4 votes
2 answers
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: ...
James111's user avatar
  • 173
4 votes
3 answers
6k views

Best practices for retrieving data scattered over multiple tables

In the company I work with, we have a 3-layer architecture in our micro-services and the flow is like this: Repository/DAO (entity) => Service (entity) => Controller (dto) At the Controller ...
Hayi's user avatar
  • 57
4 votes
2 answers
2k 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, ...
vbezhenar's user avatar
  • 141
4 votes
3 answers
2k 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 ...
Sriram Sridharan's user avatar
3 votes
1 answer
133 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 ...
Hoàng Long's user avatar
3 votes
1 answer
84 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 ...
Marco Pietro Cirillo's user avatar
3 votes
1 answer
4k views

What is the best way to manage Hibernate sessions in a Struts-1 application?

I am now the owner of a Struts-1 application, and the Hibernate session management is all over the place. I have searched online documentation but have not found a clear explanation of the best way ...
kevin cline's user avatar
  • 33.6k
3 votes
1 answer
1k 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 ...
pgs's user avatar
  • 33
3 votes
1 answer
3k views

Are there any alternatives to Hibernate Envers 3.6.2.Final?

I'm currently evaluating Hibernate Envers 3.6.2.Final; an auditing module part of Hibernate. As far as I am in my evaluation, I feel a little disappointed by Envers. I would expect much more from it ...
Stephan's user avatar
  • 135
3 votes
2 answers
392 views

What to do when putting logic into the database seems to be the only option?

I am currently working on an application that models a complex business process that consists of many steps, each having a 1:n relationship with subsequent steps. The software is written Java using ...
xgb84j's user avatar
  • 149
2 votes
1 answer
261 views

How to correctly translate UML Association, Aggregation and Composition to a Hibernate mapping?

There is a number of questions about the differences between UML Association, Aggregation and Composition out there and many many answers, some practical and some phylosofical. Here I'm asking we talk ...
AlexSC's user avatar
  • 259
2 votes
2 answers
366 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 ...
javlacerda's user avatar
2 votes
1 answer
6k 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 ...
James's user avatar
  • 283
2 votes
1 answer
1k 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; (source: ibm.com) [1] However, I am getting very confused with how data access is achieved between the data ...
FinalFind's user avatar
2 votes
1 answer
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 ...
nawara's user avatar
  • 139
2 votes
1 answer
340 views

Sorting rows off an autoincrementing primary key

Is it a bad practice to rely on an auto-incrementing primary key to sort rows in a table? A coworker and I were having an argument about this subject. We need to be able to find the last-inserted row ...
Apropos's user avatar
  • 121
2 votes
1 answer
356 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 ...
Paul Taylor's user avatar
2 votes
1 answer
111 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 ...
garci560's user avatar
  • 267
2 votes
2 answers
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 ...
amphibient's user avatar
  • 1,581
2 votes
2 answers
259 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 ...
TheOnlyIdiot's user avatar
2 votes
1 answer
258 views

Is it a good design to have separate Hibernate entities for general user info and user password digest?

I'm developing an app with a user management system. There is a database table named user with the following columns: | Column Name | Column Type | |-----------------|-------------| | userId ...
johnlinp's user avatar
  • 121
2 votes
1 answer
4k views

Best way to handle lazy models with mapstruct and spring transnational scope

In a typical Java Spring Web APP: we have the following layers: Model [DB Models] Repositories [where you have queries to DB] Services [Business service where you have the @Transactional annotation] ...
Youans's user avatar
  • 441
2 votes
1 answer
157 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 ...
TomR's user avatar
  • 1,003
2 votes
2 answers
10k 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 ...
Jignesh M. Khatri's user avatar
2 votes
1 answer
1k views

Hibernate building HQL queries

I just read hibernate reference and they say that you should use constans for HQL queries. However that is not always possible, for example if you do search function and have 10 criterias (not jpa ...
IAdapter's user avatar
  • 1,345
2 votes
0 answers
39 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....
ThinkTank's user avatar
  • 121
1 vote
4 answers
3k views

When using Hibernate can we forget about Database Design?

We started (just me and my friend) working on a website. As a part design phase we have finished the drawing a Site Map, decided on the content in each of the web page and the navigation. As we want ...
droidsites's user avatar
  • 1,027
1 vote
3 answers
816 views

infrastructure software/technologies for developing web service [closed]

[Edit: Thanks S.Lott for the hints] I'm developing a web service from scratch. The service could have potential of 10,000 requests a day. Actually, to be honest, requirements aren't that clear at this ...
sarahTheButterFly's user avatar
1 vote
1 answer
327 views

ORM: Keep entities coherent in a cache or retrieve entities each time?

We have a tricky question in a project using Java & Hibernate, with a model containing bi-directional relationships. As it's a small project with few users, few entities, and few rows involved in ...
cporte's user avatar
  • 113
1 vote
1 answer
587 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 ...
Mik378's user avatar
  • 3,858
1 vote
1 answer
831 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....
Glorfindel's user avatar
  • 3,137
1 vote
1 answer
2k 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 ...
KayDK's user avatar
  • 11