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
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 ...
11
votes
1answer
543 views

Is this the way to use HibernateCompositeUser type for handling localized contents?

I am trying to use HibernateCompositeUser type to handle i18n specific data in my application. I am trying to use the below approach. I have a table named ...
8
votes
2answers
884 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). ...
7
votes
1answer
70 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 ...
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 ...
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 ...
5
votes
3answers
579 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 ...
5
votes
2answers
850 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 ...
5
votes
1answer
23k views

Hibernate insert with foreign key

Ι have the following database: ...
5
votes
2answers
256 views

Hibernate @OneToMany relationship

I started to play around with Hibernate since yesterday and came up with the following example of one-to-many relationship example, but I am not sure if I am doing right and I have no one around me ...
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? ...
4
votes
1answer
6k views

Many-to-many hibernate mapping if link table is having extra columns mappings

I have many-to-many mapping with extra columns in the join table. The table structure looks like this: ...
4
votes
1answer
137 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 ...
4
votes
1answer
157 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 ...
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. ...
4
votes
1answer
470 views

Dao function using hibernate

I'm just wondering if the following is the best way to write a dao function. Should I get the entity manager before the transaction and close it after the transaction every time? Should I write ...
4
votes
1answer
177 views

Generic solution to Hibernate's CriteriaQuery

I've created a little class which helps me to generalize many query cases. I have a DbService and couple methods in it. Can you please take a look at it and share some criticism? The usage of that ...
4
votes
3answers
13k 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 ...
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 ...
3
votes
1answer
105 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 ...
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 ...
3
votes
1answer
4k 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): ...
3
votes
2answers
187 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
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 ...
3
votes
1answer
128 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 ...
3
votes
1answer
3k views

Managing data access layer exceptions

I am developing a webapp using Spring MVC + Hibernate. I created a GenericDao class that implements basic data access methods, to be extended by all my concrete daos in the app. What I want advice or ...
3
votes
1answer
51 views

Hibernate - entity design with multiple dependencies

I am currently working on an API and came across the following design. ...
3
votes
1answer
2k views

Any problems in using hibernate's session.connection() to run native sql

In my project, they use Hibernate's session the below mentioned way and then save entity objects with in a transaction. ...
3
votes
0answers
33 views

Separation of database and network calls

I have a API and the corresponding service method is like this: ...
3
votes
0answers
370 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
0answers
127 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, in ...
2
votes
1answer
14k views

NHibernate session and transaction implementation

In order to create loose coupling architecture on my web applications, I have created my own implementation for ORM, in this case, NHibernate. I want you please to review the code and tell me if you ...
2
votes
2answers
639 views

Hibernate transaction advice [closed]

I'm new to Hibernate so I need some advice/direction on doing Transactions. I have a DAO like ...
2
votes
1answer
745 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, ...
2
votes
2answers
796 views

JPA method to update roles for users

In my Spring MVC app I have User and Role entities. User: ...
2
votes
1answer
139 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 ...
2
votes
1answer
583 views

Hibernate entity design with a Currency class

I have a class Currency, where I want to store business logic for working with currencies: ...
2
votes
1answer
3k 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
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
5k views

Using generic methods for basic crud operations

Regarding re-usability, is this OK? What might go wrong? What would be a better design? Performance-related issues and any other comments are welcome. ...
2
votes
1answer
72 views

ORM Entity with many similar relationships

To provide some background context, I'm implementing a web-based solution (Java, Spring, Hibernate) that allows the creation/authoring of task-centric workflow documents. Basically a workflow ...
2
votes
1answer
2k views

Hibernate proxy converter for GWT

Here's a class that converts Hibernate proxies to normal classes. This is useful with GWT for example, when sending objects loaded from database to the GWT client. Please review it. ...
2
votes
0answers
27 views

Permission Representation [closed]

I'm currently implementing permissions into an application and are trying to save this onto a database using Hibernate. There are modules with commands and the permissions are also categorized using ...
2
votes
0answers
585 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
3answers
93 views

User Id generator

Hi guys below is my code to generate random long unique Ids, I use System.nanoTime to generate long Id but now to make sure that it doesn't clash in the database with previously created Id I get all ...
1
vote
1answer
78 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 ...
1
vote
1answer
616 views

Method to Return a Hibernate Session

Can this method be improved?: ...
1
vote
2answers
177 views

Repetitive code for different Database Entities with same implementation

I have this code in LogInService ...
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 ...
1
vote
1answer
68 views

Do CriteriaQuery code more readable and elegant

I wrote the code and would like to change it to more readable and elegant: ...