Which is more efficient -> hibernate criteria-mysql query? -
I am developing a web based application using spring and hibernate-mySQL. I have a restriction that the user's name should be unique, which is a more efficient way? To use the Thank you in advance .. You should use both. In hibernation the query will allow the functionality to check the functionality that it does not exist before the user is inserted, and return a proper result or enter the appropriate exception, it is better to rely on a unique obstacle, Due to rollback with a secret error message, exceptions will be hidden within the stack. But you should also have a unique barrier to guarantee uniqueness in the case of two concurrent threads, check that the user is not present at the same time, then insert both the same user at the same time. For general questions that do not need to be dynamically composed I will use the HQL instead of criteria: Read more IMHO Hibernate criteria to check the user? Or define
unique in the database and then use a try hold?
Comments
Post a Comment