[Hibernate-JIRA] Created: (EJB-313) delete twice triggers detached entity error, but change to composite primary key and the exception is gone.
by Simon Ng (JIRA)
delete twice triggers detached entity error, but change to composite primary key and the exception is gone.
-----------------------------------------------------------------------------------------------------------
Key: EJB-313
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-313
Project: Hibernate Entity Manager
Issue Type: Bug
Affects Versions: 3.2.0.cr3
Environment: Windows XP Professional + Postgres 8.1 + Spring 2 + JPA + Hibernate 3.2.3
Reporter: Simon Ng
Attachments: DeleteTwice.zip
The attached file DeleteTwice.zip has the entire project; and the primary key is a composite primary key. Run the unit test and there is no exception, just an INFO level message of "handling transient entity in delete processing".
Next, delete RestaurantPK.java, and change Restaurant.java to use a simple primary key:
package blog.jpa.domain;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
@Entity
public class Restaurant {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String name;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Change the onSetUpInTransaction to use different SQL statement to reflect a different table
protected void onSetUpInTransaction() throws Exception {
jdbcTemplate.execute("insert into restaurant (id, name) values (1, 'Burger Barn')");
jdbcTemplate.execute("insert into restaurant (id, name) values (2, 'Veggie Village')");
jdbcTemplate.execute("insert into restaurant (id, name) values (3, 'Dover Diner')");
}
drop the table restaurant and run the unit test again. Now there is an exception
[junit] Testcase: testDeleteRestaurant(blog.jpa.dao.JpaRestaurantDaoTests): Caused an ERROR
[junit] Removing a detached instance blog.jpa.domain.Restaurant#3; nested exception is java.lang.IllegalArgumentExce
ption: Removing a detached instance blog.jpa.domain.Restaurant#3
[junit] org.springframework.dao.InvalidDataAccessApiUsageException: Removing a detached instance blog.jpa.domain.Res
taurant#3; nested exception is java.lang.IllegalArgumentException: Removing a detached instance blog.jpa.domain.Restaura
nt#3
[junit] Caused by: java.lang.IllegalArgumentException: Removing a detached instance blog.jpa.domain.Restaurant#3
[junit] at org.hibernate.ejb.event.EJB3DeleteEventListener.performDetachedEntityDeletionCheck(EJB3DeleteEventLis
tener.java:45)
The java.lang.IllegalArgumentException is specified in the JPA spec.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 5 months
[Hibernate-JIRA] Created: (HHH-2401) CLOB truncation on DB2 when using 2 or 3 byte chars (UTF8)
by Simon Jongsma (JIRA)
CLOB truncation on DB2 when using 2 or 3 byte chars (UTF8)
----------------------------------------------------------
Key: HHH-2401
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2401
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.ga
Environment: Hibernate 3.2.0 GA + JBoss 4.0.4.GA on Windows XP + DB2 UDB for ISeries V5R3 + IBM JT Open driver 4.9
Reporter: Simon Jongsma
Priority: Minor
Attachments: ClobTruncated.zip
A CLOB column is used in DB2 mapped to a String in Java with the Hibernate "Text" mapping.
The column in DB2 has a CCSID 1208 which means "UTF8" (= Unicode).
The CLOB truncation occurs when characters are used that are UTF8 coded in more than one byte.
In that the string is truncated when persisted in the database.
For example the string
"Granpré Molière†; 0123456789". This string has three diacritical marks in it.
The é and è are coded in two bytes in UTF8 and the † in three bytes.
This string will be stored as "Granpré Molière†; 012345".
So "6789" is not stored.
It appears as though Hibernate does not take into account that a character can be more than 1 byte in UTF8.
The number of missing char's at the end is exactly: string.getBytes("UTF-8").length minus string.length()
It is not a problem of DB2 or the JT Open driver:
Storing and retrieving (from a Java program) the same String directly via Jdbc into the DB2 table and retrieving it, works 100% fine.
So this clearly points to a problem somewhere in Hibernate.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
15 years, 6 months
[Hibernate-JIRA] Créée: (HHH-2086) Patch for bug HHH-2076 and to be able to use <formula> in <key> for <one-to-many>
by Xavier Brénuchon (JIRA)
Patch for bug HHH-2076 and to be able to use <formula> in <key> for <one-to-many>
---------------------------------------------------------------------------------
Key: HHH-2086
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2086
Project: Hibernate3
Type: Patch
Components: core
Versions: 3.2.0.cr4
Reporter: Xavier Brénuchon
Attachments: formula_one_to_many.patch
Hello,
There is a patch to correct bug HHH-2076 and make an improvement for HHH-944.
In fact, theses 2 cases are linked. They need, amongst other things, a formula in the right part of outer join.
This patch is simple but many class concerns (to propagate formula templates).
About formula in one-to-many :
You must have at least a column (not only formula), because it's not possible to have an Update order without at least a column. If it is the case, hibernate patch will raise an MappingException rightly.
This patch add two TestCase :
org.hibernate.test.onetoone.bidirectionnalformula. OneToOneBidirectionalFormulaTest
org.hibernate.test.onetomany.formula. OneToManyFormulaTest
Would it be possible to integrate this patch into Hibernate 3.2 ?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
15 years, 6 months
[Hibernate-JIRA] Created: (HHH-3813) Automatic flush to the join table before a criteria query
by Maxim Gordienko (JIRA)
Automatic flush to the join table before a criteria query
---------------------------------------------------------
Key: HHH-3813
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3813
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Environment: Hibernate Core 3.3.1.GA, H2 1.1.108
Reporter: Maxim Gordienko
Attachments: criteriaflush.zip
With the default flush mode Hibernate flushes query regions before queries to run SQL against actual table data.
If two entity are connected using the join table and data is queried using a criteria Hibernate does not flush to the join table.
It flushes to the entity tables though.
The attached test case produces the SQL output
Hibernate: insert into USERS (ID, NAME) values (null, ?)
Hibernate: insert into ITEMS (ID, NAME) values (null, ?)
Hibernate: select this_.ID as ID0_1_, this_.NAME as NAME0_1_, items3_.USER_ID as USER1_, items1_.ID as ITEM2_, items1_.ID as ID2_0_, items1_.NAME as NAME2_0_ from USERS this_ inner join USER_ITEMS items3_ on this_.ID=items3_.USER_ID inner join ITEMS items1_ on items3_.ITEM_ID=items1_.ID where items1_.NAME=?
But it should flush to the USER_ITEMS table before executing the criteria query.
The commented HQL query does flush to both the entity tables and the join table.
The problem is in the org.hibernate.loader.criteria.CriteriaQueryTranslator.getQuerySpaces() method.
It returns only the entity tables.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 6 months