[Hibernate-JIRA] Created: (HHH-3129) Null Role in PersitentCollection during a onCollectionRecreate() in an Interceptor
by Jose CHILLAN (JIRA)
Null Role in PersitentCollection during a onCollectionRecreate() in an Interceptor
----------------------------------------------------------------------------------
Key: HHH-3129
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3129
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.6
Environment: Any
Reporter: Jose CHILLAN
When the "onCollectionRecreate" is invoked on an Interceptor, the getRole() method returns null. After investigation,
the problem is located in the class CollectionEntry in one of its constructors and is easily solved using the patch :
public CollectionEntry(CollectionPersister persister, PersistentCollection collection)
{
// new collections that get found + wrapped
// during flush shouldn't be ignored
ignore = false;
collection.clearDirty(); //a newly wrapped collection is NOT dirty (or we get unnecessary version updates)
snapshot = persister.isMutable() ? collection.getSnapshot(persister) : null;
// -- ADDED LINE HERE --
role = persister.getRole();
collection.setSnapshot(loadedKey, role, snapshot);
}
Thanks
--
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
11 years, 10 months
[Hibernate-JIRA] Created: (HHH-2847) THIS_"."NAME": invalid identifier when using createCriteria with addOrder
by Ashish Tiwari (JIRA)
THIS_"."NAME": invalid identifier when using createCriteria with addOrder
-------------------------------------------------------------------------
Key: HHH-2847
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2847
Project: Hibernate3
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.0.5
Environment: Oracle - 10.2.0
Reporter: Ashish Tiwari
We are using hibernate 3.0.5 and once a while I see following error getting generated due to incorrect SQL generated by hibernate:
Hibernate: select systembean0_.SYSTEMID as SYSTEMID12_0_, systembean0_.Version as Version12_0_, systembean0_.NAME as NAME12_0_, systembean0_.TYPE as TYPE12_0_, systembean0_.DESCRIPTION as DESCRIPT5_12_0_ from SDSYSTEM systembean0_ order by this_.NAME asc
- SQL Error: 904, SQLState: 42000
- ORA-00904: "THIS_"."NAME": invalid identifier
This normally works but occasionally we run into the issue mentioned above. I do not see alias "this_" in the sql query and I think that causes the error to happen. Issue is caused by alias not used consistently.
In normal case the generated SQL looks like following:
Hibernate: select this_.SYSTEMID as SYSTEMID7_0_, this_.Version as Version7_0_, this_.NAME as NAME7_0_, this_.TYPE as TYPE7_0_, this_.DESCRIPTION as DESCRIPT5_7_0_ from SDSYSTEM this_ order by this_.NAME asc
I am not sure what causes this problem. Has anyone else see similar problem earlier?
I appreciate any help with this. Below is other information:
Hibernate version: 3.0.5
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="com.avaya.coreservice.admin.toolkit.common.system.SystemBean"
table="SDSYSTEM">
<id name="uniqueId" type="java.lang.String">
<column name="SYSTEMID" length="50" not-null="true"/>
<generator class="uuid"/>
</id>
<version name="version" column="Version" />
<property
name="name"
type="java.lang.String">
<column name="NAME" length="512" not-null="true"/>
</property>
<property
name="type"
type="java.lang.String">
<column name="TYPE" length="50" not-null="false"/>
</property>
<property
name="description"
type="java.lang.String">
<column name="DESCRIPTION" length="1024" not-null="false"/>
</property>
<set name="resourceBeanSet">
<key>
<column name="SYSTEMID" length="50" not-null="false"/>
</key>
<one-to-many class="com.avaya.coreservice.admin.toolkit.common.resource.ResourceBean"/>
</set>
<set name="siteBeanSet" order-by="name asc">
<key>
<column name="SYSTEMID" length="50" not-null="false"/>
</key>
<one-to-many class="com.avaya.coreservice.admin.toolkit.common.site.SiteBean"/>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
HibernateUtil.getSession().createCriteria(SystemBean.class)
.addOrder(Order.asc("name")).list();
Full stack trace of any exception that occurs:
N/A
Name and version of the database you are using:
Oracle - 10.2.0
The generated SQL (show_sql=true):
select systembean0_.SYSTEMID as SYSTEMID12_0_, systembean0_.Version as Version12_0_, systembean0_.NAME as NAME12_0_, systembean0_.TYPE as TYPE12_0_, systembean0_.DESCRIPTION as DESCRIPT5_12_0_ from SDSYSTEM systembean0_ order by this_.NAME asc
I appreciate any help with this.
Thanks,
--
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
11 years, 10 months
[Hibernate-JIRA] Created: (HHH-6215) final fields can't be set if they're public
by Bogdan Butnaru (JIRA)
final fields can't be set if they're public
-------------------------------------------
Key: HHH-6215
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6215
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.4
Environment: Hibernate 3.6.4
Reporter: Bogdan Butnaru
As far as I can tell, Hibernate 3.6.4 can set a {{final}} field, _except_ if both the field and the class it belongs to are declared {{public}}. In other words,
{noformat}
public class Test{
@Column(name = "field")
private final String field = null;
}
{noformat}
will work, as will making the class non-{{public}} and the field {{public}}, but
{noformat}
public class Test{
@Column(name = "field")
public final String field = null;
}
{noformat}
will not. The latter causes an {{org.hibernate.PropertyAccessException}} to be thrown when a {{Test}} object is initialized from the database (caused by a {{java.lang.IllegalAccessException}}).
(The message I get is _"could not set a field value by reflection setter of one.of.my.Classes.field at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:151)"_)
I looked a bit around the sources for 3.6.4 (which I downloaded earlier today) and did a little debugging, and as far as I can tell the problem is in {{DirectPropertyAccessor.getField(Class, String)}}; Specifically, line 176 reads
{noformat}
if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true);
{noformat}
that is, {{setAccessible}} is not called for {{public}} fields even if they are {{final}}. I don't know the code enough to be sure, but I believe the test should check for {{final}} too.
There is an identical line in the next method (same name but with two {{Class}} arguments, line 191); I suspect that causes the same problem, but I didn't hit that code in my case (AFAIK because I don't have inherited fields).
I'm sorry for not uploading a test case, I don't quite get how to check this, but I hope I pointed close enough to the problem.
--
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
11 years, 10 months
[Hibernate-JIRA] Created: (HHH-3345) "select new" + "join fetch" = "owner of the fetched association was not present in the select list"
by Anthony Ogier (JIRA)
"select new" + "join fetch" = "owner of the fetched association was not present in the select list"
---------------------------------------------------------------------------------------------------
Key: HHH-3345
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3345
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.4.sp1
Reporter: Anthony Ogier
I want to create a List<B>, each B containing an entity with "A" type, and I also want for each A to force fetching of its "C" property.
public class B {
private A a;
public B(A a) {
this.a = a;
}
}
@Entity
public class A {
@ManyToOne @JoinColumn
private C c;
// +get/setter ...
}
@Entity
public class C {
@Column
private String d;
// +get/setter ...
// +@OneToMany
}
Here is the HQL :
select new B(a) from A a left join fetch a.c
I have that message :
org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list
When invoking only "from A a left join fetch a.c", all is good and I have ma List<A> with its "C" properties fetched.
I think there is a little bug here ... or did I forget something ?
--
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
11 years, 10 months
[Hibernate-JIRA] Created: (HHH-4897) onFlushDirty not called if only modification was to a collection of elements
by Rob West (JIRA)
onFlushDirty not called if only modification was to a collection of elements
----------------------------------------------------------------------------
Key: HHH-4897
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4897
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2, 3.3.1
Reporter: Rob West
Attachments: InterceptorTest.jar
We are not seeing onFlushDirty get called if the only modification to a Hibernate-mapped entity is to a collection of elements (e.g. a Set<String> that maps to entries in a related table). It appears that for purposes of calling onFlushDirty, a collection property of an entity can only be considered dirty if that entity is versioned (it may still not be dirty, but it cannot be dirty unless the entity is versioned). For purposes of actually executing SQL, the collection property is properly considered to be dirty based on a call to PersistentCollection.isDirty(), but this prevents an interceptor from acting on the modifications.
I've attached a jar file that contains (source) modifications to the InterceptorTest to add an additional test case highlighting this, along with modifications to User.java and User.hbm.xml to add an additional collection of elements property. The assertNotNull on line 66 (the check of last updated) fails for me locally with the latest hibernate source downloaded from hibernate.org, which appears to be 3.3.2. We currently use 3.3.1 in production.
My original forum post is at https://forum.hibernate.org/viewtopic.php?f=1&t=1002411, which contains some additional debugging information while I was figuring out what was going on.
As a note: I left the priority here the default. This is a pretty serious issue for us though, as one of the key things we do with interceptors is auditing of changes, and this means that sometimes certain properties do not get audited. We haven't been able to identify any straightforward workaround to implement that is not either fairly invasive or leaves us open to introducing other equally or more serious bugs in our code. Suggestions welcome.
--
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
11 years, 10 months