[Hibernate-JIRA] Commented: (HBX-629) JSP fields out of order when using the Seam CRUD generator with annotated EJB3 entities
by Sam Pullara (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-629?page=co... ]
Sam Pullara commented on HBX-629:
---------------------------------
I was able to get around this issue by changing the Hibernate Annotation code, commenting out the part where it sorts them. I don't know what effect this will have on native query support as the comment indicates that is why it is being done.
Index: src/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- src/java/org/hibernate/cfg/AnnotationBinder.java (revision 15355)
+++ src/java/org/hibernate/cfg/AnnotationBinder.java (working copy)
@@ -983,12 +983,12 @@
log.debug( "Processing " + propertyHolder.getEntityName() + " " + accessType + " annotation" );
List<XProperty> properties = annotatedClass.getDeclaredProperties( accessType );
//order so that property are used int he same order when binding native query
- Collections.sort( properties, new Comparator<XProperty>() {
+/* Collections.sort( properties, new Comparator<XProperty>() {
public int compare(XProperty property1, XProperty property2) {
return property1.getName().compareTo( property2.getName() );
}
} );
- for ( XProperty p : properties ) {
+*/ for ( XProperty p : properties ) {
if ( !p.isTypeResolved() && !discoverTypeWithoutReflection( p ) && !mustBeSkipped( p, mappings ) ) {
throw new AnnotationException(
"Property " + StringHelper.qualify( propertyHolder.getEntityName(), p.getName() ) +
> JSP fields out of order when using the Seam CRUD generator with annotated EJB3 entities
> ---------------------------------------------------------------------------------------
>
> Key: HBX-629
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-629
> Project: Hibernate Tools
> Issue Type: Bug
> Environment: The version of Hibernate and Hibernate Tools that is packaged with JBoss Seam 1.0 Beta 2
> Reporter: Bruce Raggett
> Priority: Minor
> Fix For: 3.1.beta5
>
>
> If you use annotated EJB3 entities to generate a Seam CRUD application, then the generated JSPs are not really usable as the order of the fields in the generated JSPs is different from the order of the fields in the annotated EJB3 entities. This means that you have to manually edit the generated JSPs to get the fields into the correct order.
> This issue seems to exist whether the process used to generate the CRUD application is
> (a) generate a database schema from the annotated entities and then generate the CRUD application from the generated schema, or
> (b) generate the CRUD application directly from the annotated entities.
--
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
16 years, 11 months
[Hibernate-JIRA] Created: (HHH-3542) Polymorphic query with set first row and limit result set returns wrong results
by Yevgeny Shakhnovich (JIRA)
Polymorphic query with set first row and limit result set returns wrong results
-------------------------------------------------------------------------------
Key: HHH-3542
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3542
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.0.ga
Reporter: Yevgeny Shakhnovich
If we issue a polymorphic query with the specified first row and set max rows to retrieve, the query returns wrong results.
For example, you have two entities A and B implementing the same interface C.
Query query = session.createQuery("from C");
query.setMaxResults(10);
query.setFirstResult(10);
List<Object[]> result = query.list(); // will return only two records despite of tables A and B have enough records
The bug is pretty simple: the same variable is used to count total number of records and included records.This is the excerpt from org.hibernate.engine.query.HQLQueryPlan.performList
int includedCount = -1;
translator_loop: for ( int i = 0; i < translators.length; i++ ) {
List tmp = translators[i].list( session, queryParametersToUse );
if ( needsLimit ) {
// NOTE : firstRow is zero-based
int first = queryParameters.getRowSelection().getFirstRow() == null
? 0
: queryParameters.getRowSelection().getFirstRow().intValue();
int max = queryParameters.getRowSelection().getMaxRows() == null
? -1
: queryParameters.getRowSelection().getMaxRows().intValue();
final int size = tmp.size();
for ( int x = 0; x < size; x++ ) {
final Object result = tmp.get( x );
if ( !distinction.add( result ) ) {
continue;
}
// In example above first is 10 and max is 10 as well.
includedCount++;
if ( includedCount < first ) {
continue;
}
// This point is reached only when includedCount is 10 or more
combinedResults.add( result );
if ( max >= 0 && includedCount > max ) {
// break the outer loop !!!
break translator_loop;
}
The fix is also simple: add one more variable to keep the total number of records:
int includedCount = 0;
int recordCount = 0;
translator_loop: for ( int i = 0; i < translators.length; i++ ) {
List tmp = translators[i].list( session, queryParametersToUse );
if ( needsLimit ) {
// NOTE : firstRow is zero-based
int first = queryParameters.getRowSelection().getFirstRow() == null
? 0
: queryParameters.getRowSelection().getFirstRow().intValue();
int max = queryParameters.getRowSelection().getMaxRows() == null
? -1
: queryParameters.getRowSelection().getMaxRows().intValue();
final int size = tmp.size();
for ( int x = 0; x < size; x++ ) {
final Object result = tmp.get( x );
if ( !distinction.add( result ) ) {
continue;
}
/* includedCount should include only what was really included */
if ( recordCount++ < first) {
continue;
}
includedCount++;
combinedResults.add( result );
if ( max >= 0 && includedCount >= max ) {
// break the outer loop !!!
break translator_loop;
}
}
}
else {
combinedResults.addAll( tmp );
}
}
--
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
16 years, 11 months
[Hibernate-JIRA] Commented: (HHH-995) Order.ignoreCase() only works for VARCHAR types, not CHAR types
by Paul Benedict (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-995?page=co... ]
Paul Benedict commented on HHH-995:
-----------------------------------
Please add this to 3.2.x
> Order.ignoreCase() only works for VARCHAR types, not CHAR types
> ---------------------------------------------------------------
>
> Key: HHH-995
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-995
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1 beta 2
> Environment: Database: Ingres
> Hibernate: I've actually been using the Order.java from CVS with hibernate 3.0, until 3.1 is released or the ignoreCase version is added to a 3.0 release.
> Reporter: Tom Dunstan
> Priority: Minor
> Attachments: IgnoreCaseCHAR.patch
>
>
> The case insensitive ordering in org.hibernate.criterion.Order only works for VARCHAR types, not CHAR types. The attached patch makes it work for both.
> I'm not sure how expensive the type.sqlTypes( factory ) lookup is; if it's expensive you may wish to cache the result since it gets used twice now, which would make the current (attached) code of:
> boolean lower = ignoreCase && type.sqlTypes( factory )[i]==Types.VARCHAR || type.sqlTypes( factory )[i]==Types.CHAR;
> look more like:
> boolean lower;
> if(ignoreCase) {
> int sqlType = type.sqlTypes( factory )[i];
> lower = sqlType == Types.VARCHAR || sqlType == Types.CHAR;
> } else {
> lower = false;
> }
--
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
16 years, 11 months