Questions tagged [hibernate]

Historically, Hibernate facilitated the storage and retrieval of Java domain objects via Object/Relational Mapping. Today, Hibernate is a collection of related projects enabling developers to utilize POJO-style domain models in their applications in ways extending well beyond Object/Relational Mapping.

Filter by
Sorted by
Tagged with
0
votes
0answers
15 views

Springboot/hibernate queries result optimization

I am developing a Springboot application, and my requirements are the following: I have 8 sql queries, that I have to run in parallel and that return a single result. My entities using this sql ...
1
vote
2answers
618 views

Creating an instance of an unit of work (NHibernate)

I'm trying to figure out how to create a NHibernate UnitOfWork using .NET Core Dependency Injection. I was just hard-coding the ...
2
votes
2answers
269 views

JPA method to update roles for users

In my Spring MVC app I have User and Role entities. User: ...
1
vote
1answer
73 views

Copying notes takes a very long time

I am working on a Spring-MVC application in which we have note like functionality. Notes can have attachments, history, etc. There is a method to copy notes. When a note has a large number of ...
0
votes
2answers
73 views

Method Calculate User Answers

I am writing spring hibernate app to make online test and this method for calculating user grade I have one to many relations between multi-choice question and answer. Also, please check this ...
1
vote
0answers
3k views

Pagination using Spring MVC and Hibernate

My company develops a Spring web application that exposes a REST API and right now we're starting to look into pagination for the methods that load data from some heavy tables. We initially looked ...
1
vote
1answer
4k views

Map DTOs and Models within the Service Layer due to a missing Business Layer

The following is the story of a UserCredentialsDto that arrived at one of my endpoints and how it finds its way through all the layers namely REST Layer Service ...
0
votes
1answer
237 views

dataAccessLayer of nHibernate

I have created a dataAccessLayer for nHibernate. I suspect there are some bugs in the code. I am really new to nHibernate. Can anyone suggest me the best practice for creating dataAccessLayer. I ...
1
vote
0answers
56 views

Educational Hibernate project to create / delete / change accounts

I had to write a module for educational purposes that responsible for storing and processing clients information. Clients can have accounts. There should also be a console menu that allows you to: ...
-1
votes
1answer
691 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 ...
1
vote
1answer
1k views

Spring MVC @ControllerAdvice exception handling

This is about handling sql - foreign key constraint failure exceptions (SQL Error: 1452, SQLState: 23000) globally using ...
4
votes
3answers
10k 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 ...
0
votes
1answer
44 views

Implementation of getUsersWithStatuses based on getUsersWithStatus

In my code I have method which gets users from database with concrete status. And now I have to add new method which gets users from database with list of statuses. I don't know, is it better to ...
1
vote
0answers
493 views

Uploading an image for a product in an online store

I am creating an online store using Spring MVC. The point is that when you create a new product you need to upload a picture for it. I am using the Cloudinary service, so when you upload, the image ...
0
votes
2answers
58 views

Hibernate MassIndexer using chained invocation for building a batch job

I've a class called MassIndexer.java (on GitHub) and it uses chained invocation for building a batch job. Each method assigns a property of this job and finally the ...
5
votes
3answers
483 views

ISBN validation with Hibernate Validator

I've written a ISBN-validating annotation. It is to be used in conjunction with Hibernate Validator. I'm pretty satisfied with this code as it works as expected, but I've had to make a design choice ...
2
votes
0answers
326 views

NBP currency application

I have a small program in Java with GUI, which is showing NBP currency data in specified tabs. It downloads data from www.nbp.pl using XML format and saving it into Apache Derby database using ...
3
votes
1answer
100 views

Overloaded applyRestrictionsToCriteria(…) methods

We want to refactor two methods that are exactly the same, except for one difference: one takes an org.hibernate.Criteria and the other ...
4
votes
1answer
132 views

Code for my first crud app

I would like to ask more experienced developers to review my code, it's my first app, self-made, I know there is a lot to improve, it would be great if you could just point the main errors. I'm ...
1
vote
1answer
61 views

improved HibernateDao

I have this HibernateDAO.java Class: ...
1
vote
1answer
65 views

Do CriteriaQuery code more readable and elegant

I wrote the code and would like to change it to more readable and elegant: ...
1
vote
1answer
52 views

Hibernate Save method practice

We are new into hibernate, in our project for saving an entry the below given code is used, please have a look. ...
1
vote
1answer
79 views

Hibernate Native Query

This is my code to populate a Class and later convert it to JSON object. ...
3
votes
0answers
118 views

Implementing a long-running entity lock

Requirement I have an entity named ImportData which can be processed once in order to extract data from a file fed to the application. I need to make sure that, ...
0
votes
1answer
45 views

Dynamic field performance

A have a model with a dynamic field like so: ...
3
votes
1answer
3k views

Customize data types in a generated model with hibernate

I have a Spring/Hibernate application with the following domain class (irrelevant code stripped for brevity): ...
2
votes
1answer
135 views

Counting nonexisting records with foreign key

I have two tables Room and RoomDate. Here's the structure for Room Room roomID checkInDate checkOutDate roomType Here's the structure for RoomDate. They have a ...
1
vote
0answers
970 views

Generic DAO implementation

I wrote a generic DAO and two DAOs extending from it. I'm new at this pattern so I'm not sure if I'm doing this correctly. It seems to work fine though. I am using Hibernate for database access. Here ...
1
vote
0answers
177 views

Update operation with hibernate

I am creating a project about hotel reservations. I created a udirection one to many relationship between users and reservations. That is, A user can have many reservations. Here is the User class. <...
4
votes
0answers
4k views

Hibernate and the Repository Pattern

I have already asked a question on stackoverflow on how to understand the Reporitory Pattern but I'm still having very big troubles in getting a good design implemented on my server. I'm desperately ...
1
vote
1answer
50 views

Retrieving three separate sorted lists of items

I need to search for records based on their area, postcode, city and sort each group ...
6
votes
1answer
5k views

JMS consumer for message retrieval and listening

I created a standalone Java application that acts as a consumer that retrieves/listens for messages inside an ActiveMQ queue. Planning to run two instances of these on different machines for high ...
2
votes
1answer
1k views

Moving DTOs between server/client

I am developing a server for a web-client. Basically it's just a simple CMS to modify some data. My problem is that I never had a project like this where I have to take care about the server and the ...
2
votes
1answer
464 views

Hibernate entity design with a Currency class

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

Hibernate insert with foreign key

Ι have the following database: ...
12
votes
1answer
7k views

Onion Architecture

After doing a whole bunch of research on Onion Architecture, I have made an attempt at implementing this in a new system that we are developing. We have the Layers as per below: Domain ...
8
votes
2answers
773 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
0answers
554 views

Nhibernate repository for MVVM applications

I am developing a single user .net desktop application that lists numerous (over 2000) contacts sorted by an algorithm. I use NHibernate and did consider a session ...
1
vote
1answer
595 views

Method to Return a Hibernate Session

Can this method be improved?: ...
3
votes
1answer
154 views

Automagic (or not quite so) Domain Model Class Validation

The Task I was assigned a small task, concerning validation of Domain-Model classes. The Validation for a String property of one of our Models was required to be unique across the whole Table. And ...
3
votes
2answers
184 views

Performance enhancement for collection manipulation

I have below snippet of code which gets all the available menu items for a zone(top or left)and adds the widgets for which user has access to an ArrayList collection. For now the getWidgetsByZone(zone)...
3
votes
1answer
2k views

Optimization of Hibernate DAO in desktop application

I'm working on medium sized desktop application (with around 100 tables in database). For persistence layer I decided to use Hibernate for the first time to avoid massive redundancy of code for ...
5
votes
2answers
807 views

Method for executing any type of HQL

I have written two methods that executes any type of HQL and returns data. Methods are like ...
3
votes
2answers
1k views

A flexible unit-of-work + repository pattern

Searching on Stack Overflow and Google, I find many and many different implementation for Unit-of-Work/Repository patterns, but none of that really convinced me; each had some small defect that ...
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 ...
2
votes
1answer
2k views

Generic util method to convert in single map from list of array of Object generally result of JPQL/ hibernate

I have designed a generic method to convert list of array of Objects to result into single map. This is working fine, but I want to check weather a key object is valid key (whether it is overriding ...
2
votes
1answer
631 views

JUnit - Test whether object was persisted or not

I am using Hibernate 4 and Spring Framework 4. I wrote a simple test to check whether object was persisted or not. All set values in confirmationEntity are required. In this test I relly on that, ...
5
votes
1answer
3k views

Create better Base DAO class

I created a DAO class which is base class for all other DAO classes. I use Spring Framework 4 and Hibernate 4. Question: Is there anything that could be done better? ...
3
votes
1answer
124 views

Loading, computation and writing 500.000 rows in database

first let me explain what I am trying to achieve here : I am supposed to compute some results, using data from several tables, filtered by a run_id. One of these tables has about 500.000 rows per ...
7
votes
1answer
5k views

NHibernate select with Query Over optimization for user roles base case

I have a complicated select procedure that I solved with a 5 query select, so I am posting it here to get suggestions on how I can shorten it up a bit. I am hoping that someone can help me make it a ...