[Hibernate-JIRA] Created: (HHH-3843) @Audited and @ManyToMany relation problem - after modyfing an Entity: org.hibernate.NonUniqueObjectException with message: "a different object with the same identifier value was already associated with the session ...
by Michał Maryniak (JIRA)
@Audited and @ManyToMany relation problem - after modyfing an Entity: org.hibernate.NonUniqueObjectException with message: "a different object with the same identifier value was already associated with the session ...
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-3843
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3843
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.3.1
Environment: envers.jar 1.2.0, Hibernate 3.3.1, postgresql-8.3, jboss-4.2.3
Reporter: Michał Maryniak
Attachments: enverse.7z
There is a problem with unidirectional @ManyToMany relation.
This case is different than the one with inheritance: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3830.
The example is trival and code is as simple as it can be.
A single Person can have many roles, and one Role can by assigned to many Person entities.
@Entity
@Audited
public class Person implements Serializable {
(...)
@ManyToMany
public List<Role> getRoles() {
return roles;
}
(...)
}
and
@Entity
@Audited
public class Role implements Serializable {
(...)
}
And here comes a use case:
1) I create role 'admin'
2) I create role 'user'
3) I create person 'john' and add him a role 'admin'
4) I edit 'john' and add him second role 'user'
and I got an exception:
org.hibernate.NonUniqueObjectException with message: "a different object with the same identifier value was already associated with the session: [Person_Role_AUD#{roles_id=1, Person_id=5, REV=DefaultRevisionEntity(id = 7, revisionDate = 2009-04-01 10:46:32)}]"
If I add one role and remove the second one, or if I only remove a role - an Exception does not occur.
I attached a zip file with this simple SEAM project generated by seam-gen 2.1.1 GA.
I haven't included jar files, but project requires jar's "generated" with seam-gen (2.1.1) and following jar's have been replaced with new ones:
2008-06-13 13:09 313˙898 dom4j.jar 1.6.1
2009-03-23 13:01 285˙158 envers.jar 1.2.0-hibernate-3.3
2008-08-20 11:27 279˙714 hibernate-annotations.jar 3.4.0.GA
2008-08-20 11:31 66˙993 hibernate-commons-annotations.jar 3.1.0.GA
2008-08-20 12:19 119˙292 hibernate-entitymanager.jar 3.4.0.GA
2008-12-04 14:39 304˙236 hibernate-search.jar 3.1.0.GA
2008-09-10 14:01 62˙574 hibernate-validator.jar 3.1.0.GA
2008-09-10 13:27 2˙766˙130 hibernate.jar from hibernate-distribution-3.3.1.GA-dist
2008-06-13 13:09 13˙236 jta.jar 1.1 (from hibernate-distribution-3.3.1.GA-dist)
2008-12-04 14:41 818˙961 lucene-core.jar 2.4.0 701827 - 2008-10-05 16:44:37
2008-08-19 20:40 17˙384 slf4j-api.jar 1.5.2
If you wish - I can attach a file with my oryginal jar - but it would be a realy big file ;-)
--
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
13 years, 2 months
[Hibernate-JIRA] Created: (HHH-3440) 3.3.0 GA with MySQL 5.0 throws table validation exception
by Carlo Luib-Finetti (JIRA)
3.3.0 GA with MySQL 5.0 throws table validation exception
---------------------------------------------------------
Key: HHH-3440
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3440
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.3.0.GA
Environment: Hibernate 3.3.0 GA
MySQL 5.0
JBoss 4.2.2
Reporter: Carlo Luib-Finetti
Hibernate immediately throws an exception at application startup, when it does the schema validation.
org.hibernate.HibernateException: Wrong column type in dpjw.assessment for column NOTES. Found: text, expected: longtext
Comparing the sources of 3.2.0 with 3.3.0 I can see that someone set two java statements into comment. The 3.2 version of MySQLDialect.java looks like this:
protected void registerVarcharTypes() {
registerColumnType( Types.VARCHAR, "longtext" );
registerColumnType( Types.VARCHAR, 16777215, "mediumtext" );
registerColumnType( Types.VARCHAR, 65535, "text" );
registerColumnType( Types.VARCHAR, 255, "varchar($l)" );
}
while the new 3.3.0 version is this:
protected void registerVarcharTypes() {
registerColumnType( Types.VARCHAR, "longtext" );
// registerColumnType( Types.VARCHAR, 16777215, "mediumtext" );
// registerColumnType( Types.VARCHAR, 65535, "text" );
registerColumnType( Types.VARCHAR, 255, "varchar($l)" );
}
If I uncomment these (and others in the same Java file!), the validation process is ok.
Is there any reason why these statements (and others!) were commented out???
--
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
13 years, 2 months
[Hibernate-JIRA] Created: (HHH-3530) The code in the 3.3.1.GA subversion tag is not the code that's been released on the maven repository.jboss.org as 3.3.1.GA
by Geoffrey De Smet (JIRA)
The code in the 3.3.1.GA subversion tag is not the code that's been released on the maven repository.jboss.org as 3.3.1.GA
--------------------------------------------------------------------------------------------------------------------------
Key: HHH-3530
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3530
Project: Hibernate Core
Issue Type: Bug
Components: build
Affects Versions: 3.3.1
Reporter: Geoffrey De Smet
Here's the proof:
http://fisheye.jboss.org/browse/Hibernate/core/tags/hibernate-3.3.1.GA/co...
contains the lines (44-45):
registerColumnType( Types.CLOB, "longtext" );
registerColumnType( Types.CLOB, 16777215, "mediumtext" );
registerColumnType( Types.CLOB, 65535, "text" );
But the sources jar downloaded from
http://repository.jboss.org/maven2/org/hibernate/hibernate-core/3.3.1.GA/...
file
org\hibernate\dialect\MySQLDialect.java
so on my pc
C:\Documents and Settings\gds\.m2\repository\org\hibernate\hibernate-core\3.3.1.GA\hibernate-core-3.3.1.GA-sources.jar!\org\hibernate\dialect\MySQLDialect.java
has these lines (66-68) instead:
registerColumnType( Types.CLOB, "longtext" );
// registerColumnType( Types.CLOB, 16777215, "mediumtext" );
// registerColumnType( Types.CLOB, 65535, "text" );
It's not just some copyright stuff that been added (giving it different line numbers), some lines are clearly commented out.
Maybe untagged changes happened in other files too?
--
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
13 years, 2 months
[Hibernate-JIRA] Created: (HHH-3930) one-to-one causes redundant select query
by Martijn Dashorst (JIRA)
one-to-one causes redundant select query
----------------------------------------
Key: HHH-3930
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3930
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Reporter: Martijn Dashorst
@Entity
public class Address {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToOne(mappedBy = "address")
private Customer customer;
}
@Entity
public class Customer {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private Address address = new Address();
public Long getId() {
return id;
}
public Address getAddress() {
return address;
}
}
This mapping causes 2 instead of the expected 1 query to retrieve a Customer and its Address from the db:
select * from Customer customer0_ left outer join Address address1_ on customer0_.address_id=address1_.id where customer0_.id=?
select * from Customer customer0_ left outer join Address address1_ on customer0_.address_id=address1_.id where customer0_.address_id=?
Changing the mapping to a LAZY fetch type:
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Address address = new Address();
Causes 3 select queries instead of the expected 2 queries to retrieve a Customer (and its Address) from the db:
select * from Customer customer0_ where customer0_.id=?
select * from Address address0_ left outer join Customer customer1_ on address0_.id=customer1_.address_id where address0_.id=?
select * from Customer customer0_ where customer0_.address_id=?
The third select is superfluous because the relationship is already completely known: you already have the customer, so why not just set it on the address entity?
Making the address field in Customer a @ManyToOne doesn't make a difference.
Making the customer field in Address a @OneToMany does remove the extra select, but forces our model to change the relationship from Customer to List<Customer> where we *know* there'll be only 1 element.
Apparently Hibernate can figure out the reverse relationship with a @ManyToOne - @OneToMany without the need for additional queries, can't this be extended to @OneToOne bidirectional relationships as well?
--
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
13 years, 2 months
[Hibernate-JIRA] Created: (HHH-2866) The order of parameters is not maintained between HQL and SQL, but the parameters are inserted into the PreparedStatement in their HQL order.
by Benjamin Keil (JIRA)
The order of parameters is not maintained between HQL and SQL, but the parameters are inserted into the PreparedStatement in their HQL order.
---------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2866
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2866
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.5
Environment: Hibernate 3.2.5.ga; both with MySQLInnoDB and H2 dialects; both with annotations and hand written mapping files
Reporter: Benjamin Keil
Attachments: ReorderedParameters.java, ReorderedParameters.zip
The HQL query
from Assoc a where a.type.oid = ? and a.constituents[?].oid = ?
gets translated into
select
reorderedp0_.oid as oid1_,
reorderedp0_.type_oid as type2_1_
from
Assoc reorderedp0_,
Assoc_Topic constituen1_,
Topic reorderedp2_
where
reorderedp0_.oid=constituen1_.Assoc_oid
and constituen1_.topic_index = ?
and constituen1_.constituents_oid=reorderedp2_.oid
and reorderedp0_.type_oid=?
and reorderedp2_.oid=?
Where clearly the first and second parameters (the index and the type) have been permuted.
The relevant thread in the User forum is : http://forum.hibernate.org/viewtopic.php?t=979832
Attached are a java source file that demonstrates the error, and a zipped maven2 project that supplies the Hibernate, Hibernate-Annotation, H2, and Log4J dependencies.
--
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
13 years, 3 months