[Hibernate-JIRA] Created: (ANN-617) NullPointerException when handling @OrderBy
by Jifeng Liu (JIRA)
NullPointerException when handling @OrderBy
-------------------------------------------
Key: ANN-617
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-617
Project: Hibernate Annotations
Issue Type: Bug
Components: binder
Affects Versions: 3.3.0.ga
Environment: Hibernate Core 3.2.4.SP1; Hibernate Annotations 3.3.0 GA; Hibernate EntityManager 3.3.1 GA; Oracle OC4J; Oracle DB 10g
Reporter: Jifeng Liu
After I updated from Hibernate Annotations 3.2.1ga to 3.3.0ga, I get the following NullPointerException:
Caused by: java.lang.NullPointerException
at org.hibernate.cfg.annotations.CollectionBinder.buildOrderByClauseFromHql(CollectionBinder.java:851)
at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1133)
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:576)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:517)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:316)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:416)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:138)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:114)
at com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl.createContainerEntityManagerFactory(PersistenceUnitManagerImpl.java:175)
After I debug it, the variable 'pc' is null in the CollectionBinder.java:851 line:
table = pc.getTable().getQuotedName() + ".";
It seems like this bug is introduced by fix of ANN-516 '@OrderBy added to wrong table in inheritance relationship'.
The related persist classes are:
// ------ The class with @OrderBy annotation
@Entity
@Table(name="RG_SECTION")
@IdClass(SectionID.class)
public class Section extends AbstractSection{
@ManyToMany(fetch=FetchType.EAGER)
@JoinTable(name="V_Current_Section_Term",
joinColumns= {
@JoinColumn(name="Section_School_Id", referencedColumnName="School_Id"),
@JoinColumn(name="Section_ID", referencedColumnName="Section_ID")},
inverseJoinColumns= {
@JoinColumn(name="Term_School_Id", referencedColumnName="School_Id"),
@JoinColumn(name="Term_Academic_Yr", referencedColumnName="Academic_Yr"),
@JoinColumn(name="Term_Sort_No",referencedColumnName="Term_Sort_No")}
)
@OrderBy("termSortNo")
public List<Term> getTerms() {
return super.getTerms();
}
// -------------- This Entity class in the Collection ---------
@Entity
@Table(name="SCHOOL_TERMS")
@IdClass(TermID.class)
public class Term extends AbstractBusinessObject implements Comparable{
....
--
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
17 years, 5 months
[Hibernate-JIRA] Commented: (HHH-1311) Session.load is O(n) when outside a transaction
by Matt Sgarlata (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1311?page=c... ]
Matt Sgarlata commented on HHH-1311:
------------------------------------
I am trying to use Hibernate to render a screen with around 9,000 data points and about 2,000 objects in the session-level cache. JProbe shows that 50.2% of the time it takes for this screen to render is up by StatefulPersistenceContext.afterTransactionCompletion(). So, half of request processing time is used to retrieve items that are already in memory and part of the cache!
The only reason I said it was outside a transaction is because StatefulPersistenceContext.afterTransactionCompletion() is called as part of JDBCContext.afterNontrasnactionalQuery(boolean).
> Session.load is O(n) when outside a transaction
> -----------------------------------------------
>
> Key: HHH-1311
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1311
> Project: Hibernate3
> Issue Type: Improvement
> Components: core
> Affects Versions: 3.0.5
> Reporter: Matt Sgarlata
>
> When retrieving objects from the session-level cache, session.load is O(n) when outside a transaction, where n = the number of objects currently contained in the session-level cache. This is because after each object is retrieved Hibernate iterates through all objects in the session and sets the lock mode to LockMode.NONE. This means reading all objects from the Hibernate session-level cache while outside a transaction is an O(n^2) operation instead of an O(n) operation.
> If my understanding is correct, all objects in the session should already have that lock mode unless a different lock mode was specifically requested by the user. Thus iterating through all objects in the session is not necessary in the vast majority of cases. I think performance could be improved here by maintaining a cache of the objects in the session that are currently locked. Then performance of session.load would be O(m) where m is the number of objects which are currently locked in the session. In the vast majority of cases this would effectively make session.load a O(1) operation since objects in the session typically are not locked.
> The other solution for me, of course, would be to just wrap all web requests so that I begin transactions at the start of the request and end transactions at the end of the request. However, I don't want to do that because transactions require database resources and I feel it's not necessary to incur that overhead on the read-only screens in my application.
--
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
17 years, 5 months
[Hibernate-JIRA] Created: (ANN-608) NullPointerException from AnnotationConfiguration with specific order of calling addResource and addPackage when package-info.java present
by Steve Gilbert (JIRA)
NullPointerException from AnnotationConfiguration with specific order of calling addResource and addPackage when package-info.java present
------------------------------------------------------------------------------------------------------------------------------------------
Key: ANN-608
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-608
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga
Environment: Hibernate 3.2.3
Reporter: Steve Gilbert
Attachments: Main.java, orm.xml, package-info.java
There is a bug in AnnotationConfiguration that causes a NullPointerException.
I have attached several files: orm.xml, Main.java, package-info.java.
The problem is caused by the order of the addResource and addPackage calls in combination with having a package-info.java file with some contents. If the addPackage is called before the addResource, or if the GenericGenerator annotation in the package info file is removed, there is no problem.
I cannot change the order of those calls for my production code, however, because Spring is being used to create the SessionFactory and it calls the methods in that order: resource followed by package.
There appears to be a problem with initializing
org.hibernate.cfg.annotations.reflection.EJB3OverridenAnnotationReader. When this call is made on line 360:
annotationsMap.put( ann.annotationType(), ann );
the map is null. Inserting a creation for the map, (borrowed from elsewhere in the method) on line 359, before the "for" statement:
annotationsMap = new HashMap<Class, Annotation>( annotations.length + 5 );
resolves 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
17 years, 5 months
[Hibernate-JIRA] Created: (HHH-2724) Update EJBQL query generating bad SQL
by Jonathan O'Connor (JIRA)
Update EJBQL query generating bad SQL
-------------------------------------
Key: HHH-2724
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2724
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.4.sp1
Environment: Hibernate version: 3.2.4SP1 with 3.3.1GA EntityManager and 3.3.0GA Annotations, running on Postgresql 8.1
Reporter: Jonathan O'Connor
Attachments: test.jar
The generated SQL (show_sql=true):
update Person set name=? where (id in (select customer1_.id from Customer customer1_ ) ) and person0_.name<>?
My EJBQL query is:
update Person set name = ?1 where id in (select c.id from Customer c) and name <> ?2
The generated SQL refers to an unknown table alias "person0_".
A workaround is to change around the conditions in the where clause. That is:
update Person set name = ?1 where name <> ?2 and id in (select c.id from Customer c)
does not generate bad code. If I add a where clause to the inner select, then the problem also goes away. Finally, correct SQL is generated in the matching select.
Doing a delete instead of update also causes bad code, and the workarounds are also the same:
delete Person where id in (select id from Customer) and name <> 'Y'
The attached jar file has two classes Person and Customer. There is also a persistence.xml in the META-INF directory. ts configured for a local postgres system. You may need to alter this file. I tested the SQL generation using Hibernate Tools plugin for Eclipse.
--
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
17 years, 5 months
[Hibernate-JIRA] Commented: (HHH-1657) hql update generate wrong sql with joined subclass hierarcy
by Tamir Solomon (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1657?page=c... ]
Tamir Solomon commented on HHH-1657:
------------------------------------
Hi.
i have the same issue as David
the update query is :
update ADSocket remoteSocket set remoteSocket.twinSocket = (select localSocket from ADSocket localSocket " +
"where localSocket.isLocalSocket=true and " +
"(remoteSocket.ip!=null and localSocket.ip=remoteSocket.ip and " +
"remoteSocket.port=localSocket.port " +
"and remoteSocket.isServerSocket=localSocket.isServerSocket))
where as the generated sql is :
Hibernate: insert into #AD_SOCKET select adsocket0_.SO_SOCKET_ID as SO_SOCKET_ID from AD_SOCKET adsocket0_ inner join AD_ENTITY adsocket0_1_ on adsocket0_.SO_SOCKET_ID=adsocket0_1_.EN_ID where ( EN_IS_DELETED is null or EN_IS_DELETED = 0) and SO_DETECTION_SERVER_ID=? and SO_IS_LOCAL=0
Hibernate: update AD_SOCKET set SO_TWIN_SOCKET=(select SO_SOCKET_ID from AD_SOCKET adsocket1_ inner join AD_ENTITY adsocket1_1_ on adsocket1_.SO_SOCKET_ID=adsocket1_1_.EN_ID where ( adsocket1_1_.EN_IS_DELETED is null or adsocket1_1_.EN_IS_DELETED = 0) and adsocket1_.SO_IS_LOCAL=1 and (adsocket0_.SO_IP is not null) and adsocket1_.SO_IP=adsocket0_.SO_IP and adsocket0_.SO_PORT=adsocket1_.SO_PORT and adsocket0_.SO_IS_SERVER_SOCKET=adsocket1_.SO_IS_SERVER_SOCKET) where (SO_SOCKET_ID) IN (select SO_SOCKET_ID from #AD_SOCKET)
Hibernate: insert into #AD_SOCKET select adsocket0_.SO_SOCKET_ID as SO_SOCKET_ID from AD_SOCKET adsocket0_ inner join AD_ENTITY adsocket0_1_ on adsocket0_.SO_SOCKET_ID=adsocket0_1_.EN_ID where ( EN_IS_DELETED is null or EN_IS_DELETED = 0)
Hibernate: update AD_SOCKET set SO_TWIN_SOCKET=(select SO_SOCKET_ID from AD_SOCKET adsocket1_ inner join AD_ENTITY adsocket1_1_ on adsocket1_.SO_SOCKET_ID=adsocket1_1_.EN_ID where ( adsocket1_1_.EN_IS_DELETED is null or adsocket1_1_.EN_IS_DELETED = 0) and adsocket1_.SO_IS_LOCAL=1 and (adsocket0_.SO_IP is not null) and adsocket1_.SO_IP=adsocket0_.SO_IP and adsocket0_.SO_PORT=adsocket1_.SO_PORT and adsocket0_.SO_IS_SERVER_SOCKET=adsocket1_.SO_IS_SERVER_SOCKET) where (SO_SOCKET_ID) IN (select SO_SOCKET_ID from #AD_SOCKET)
and the error from the DB is (on the last update statement):
com.sybase.jdbc3.jdbc.SybSQLException: ASA Error -142: Correlation name 'adsocket0_' not found
Anyone ??
T.
> hql update generate wrong sql with joined subclass hierarcy
> -----------------------------------------------------------
>
> Key: HHH-1657
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1657
> Project: Hibernate3
> Issue Type: Bug
> Components: query-hql
> Environment: Hibernate 3.2.0cr1, Hibernate 3.1.3
> Reporter: Alexey Romanchuk
> Priority: Critical
>
> Let suppose that we have two joined subclass entities: Parent (id PK) and Child (id PK) that mapped with joined subclass method.
> When I try to update Child by id with hql:
> update Child c set c.field = 'value' where c.id = 1234
> hibernate generates joined tables like
> insert into HT_parent select child0_.id as id from child child0_ inner join parent child0_1_ on child0_.id=child0_1_.id wher id in = 1234
> look at last condition. hibernate use id WITH OUT tables alias that cause sql exception: column reference "id" is ambiguous
--
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
17 years, 5 months