Skip to main content
5 votes

Copying notes takes a very long time

You said that the method addAttachmentForCopy() is taking a lot of time. This method is doing some DAO operations, but also a few file reading operations. Are you ...
antonro's user avatar
  • 302
5 votes

User Id generator

Code review UserIdFactoryImpl Why is this called Impl if it does not extend an interface? Why isn't it ...
Maarten Bodewes's user avatar
4 votes
Accepted

Overloaded applyRestrictionsToCriteria(…) methods

Vector vs List/ArrayList Vector was retrofitted to be ...
h.j.k.'s user avatar
  • 19.2k
3 votes
Accepted

A vanilla Hibernate app (no Spring)

I suspect catching all Exceptions is bad practice (as opposed to catching specific exceptions). It depends... As long as you have the same reaction to all kinds of possible exceptions (just logging ...
Timothy Truckle's user avatar
3 votes
Accepted

Refactoring duplicated code with abstraction and generics

common Interface classes that share the same behaviour should implement the same interface. That applies to Movie, Book and <...
Martin Frank's user avatar
  • 2,838
3 votes
Accepted

ISBN validation with Hibernate Validator

I would not use an Optional here. Instead, I would have the method checkISBN receive the ...
Tunaki's user avatar
  • 9,233
3 votes

ISBN validation with Hibernate Validator

Why did you include Optional when it doesn't seem to be doing anything special? To me, it seems you've just used Optional as a ...
Pimgd's user avatar
  • 22.3k
3 votes
Accepted

Code for my first crud app

This is by no means a comprehensive review, just some little things that I would change. You are often injecting HttpServletRequest and HttpServletResponse as method arguments. This is not necessary ...
ASA's user avatar
  • 463
2 votes

Implementation of getUsersWithStatuses based on getUsersWithStatus

I would say that in your case it is not a good idea because you will execute the same query many times. However you can change you calls to have the method with a single status calling the one with ...
gervais.b's user avatar
  • 2,067
2 votes
Accepted

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

I've had a lot of occasions to face similar problems, but must admit that there is no ideal solution. It is difficult to avoid code duplications in JPA entities definitions. However, there are some ...
Antot's user avatar
  • 3,657
2 votes
Accepted

Spring MVC @ControllerAdvice exception handling

Your approach seems well written and structured code-wise. However I feel that there is room to improve the structure of the application and the separation of concerns among the classes thus producing ...
Panayiotis Poularakis's user avatar
2 votes

Generic solution to Hibernate's CriteriaQuery

Welcome to Code Review, I have seen your code and I have seen you encapsulated your createQuery method like below: ...
dariosicily's user avatar
  • 3,961
2 votes

User Id generator

As Maarten and Torben already pointed out, creating a user id that way is a terrible idea. I'd like to go one step further and add, that creating a userId as a primary key technical identifier for a ...
mtj's user avatar
  • 4,822
2 votes

User Id generator

Adding to Maarten Bodewes' answer, checking if a user ID exists by loading all user identifiers from database and checking if the ID exists in the result set is extremely inefficient and as Maarten ...
TorbenPutkonen's user avatar
1 vote
Accepted

Is it good way to user dao when assembling dto to entity or not?

Entity Relationships First you could draw the ER diagram to visualize entity-relations. An UML class-diagram for Order could do, like this: ...
hc_dev's user avatar
  • 822
1 vote

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

It's a lot to explain here, but in a nutshell, I would simplify all of this using spring-data-rest and do the following Get rid of the REST/persistence/dao layers you have Refactor your services to ...
Christian Bongiorno's user avatar
1 vote

dataAccessLayer of nHibernate

Excepiton handling Almost all of your try/catch blocks are meaningless (at least those with only throw ex;). If all you do is to ...
t3chb0t's user avatar
  • 44.3k
1 vote
Accepted

Hibernate - entity design with multiple dependencies

I don't see anything wrong with your approach. Another option is to add a PhoneNumberType to the PhoneNumber table. In any case you should ensure the table has ...
dustytrash's user avatar
  • 2,406
1 vote

Creating an instance of an unit of work (NHibernate)

In some camps it is not advised to tightly couple your code to framework specific dependencies like IConfiguration. Based on the shown constructor it looks like ...
Nkosi's user avatar
  • 3,246
1 vote
Accepted

JPA method to update roles for users

The biggest optimization potential I see is readability. Note that forEach() does not have any advantage over a good-ole-for-loop from a technical perspective, but in many cases makes the code more ...
mtj's user avatar
  • 4,822
1 vote

JPA method to update roles for users

Well, you created a good code so far. Your lamda is OK. But there are some things about naming which could be improved About the API setRolesByUserId, it is OK to ...
kidnan1991's user avatar
1 vote

Inserting 100000 records to MySQL takes too much time

Using batch-inserting is one of the methods to decrease a saving time, but still not enough to handle 100k records in 5 or less seconds due to ORM internal mechanism. I suggest you to look into your ...
Sardor Navruzov's user avatar
1 vote

Inserting 100000 records to MySQL takes too much time

I think it's your transaction set up. Without being able to run the code I would guess that the transaction overhead is the bottleneck. Check out the Insert example here: https://docs.jboss.org/...
Alzoid's user avatar
  • 141
1 vote

Hibernate MassIndexer using chained invocation for building a batch job

Try to avoid allowing the invocation chain to go from a valid object to an invalid object. Your setJavaSE allows that. Instead you can make a method ...
ratchet freak's user avatar
1 vote
Accepted

Hibernate MassIndexer using chained invocation for building a batch job

Make a second level Builder class ...
Joop Eggen's user avatar
  • 3,536
1 vote

ISBN validation with Hibernate Validator

Remove unnecessary dependencies Try to minimize the "invasion" of additional libraries if you can simply say string.replace("-",""). ...
oopexpert's user avatar
  • 3,132
1 vote
Accepted

improved HibernateDao

I would definitely try to migrate your DAO to a JPA compliant code. This way you don't have to manage the sessions yourself and you focus in CRUD operations. It would be enough setting up an entity ...
Aritz's user avatar
  • 355

Only top scored, non community-wiki answers of a minimum length are eligible