Skip to main content

Posts

Showing posts from February, 2016

CASCADE Vs RESTRICT Vs NO ACTION Vs SET NULL in MYSQL

The table containing the foreign key is called the   referencing   or   child table , and the table containing the candidate key is called the   referenced   or   parent table .   SET NULL   : Sets the column value to   NULL   when you delete the parent table row. CASCADE   : CASCADE will   propagate the change   when the parent changes. If you delete a row, rows in constrained tables that reference that row   will also be deleted , etc.  

Resolution for Error: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey

Error: "javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey" I was  trying to implement Hibernate Search functionality on my current project. I faced the above issue and resolved it with some research. Root cause and Solution:   JoinColumn.foreignKey() was introduced with JPA 2.1, which was not implemented by Hibernate 4 until version 4.3. If you're using an older version of Hibernate 4, you will face this issue. Try to upgrade it to hibernate-jpa-2.1-api   and also Hibernate to 4.3.x. If you're already using Hibernate 4.3 then make sure you're also using hibernate-jpa-2.1-api to make sure the API and implementation match up.

Resolved: “org.hibernate.ObjectNotFoundException: No row with the given identifier exists” but it does exists

Error: “org.hibernate.ObjectNotFoundException: No row with the given identifier exists” but it does exists. I was facing this issue with my current project. There might be 2 possible reasons to occur this error. Root Causes: 1. Whene there is relationship between two tables in the database, the main entity may not exists in the database, You can check it with session.get() method whether it is there or not.