[Hibernate-JIRA] Created: (HHH-2155) mysql dialect should not generate automatically index for foreign key
by Anthony Patricio (JIRA)
mysql dialect should not generate automatically index for foreign key
---------------------------------------------------------------------
Key: HHH-2155
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2155
Project: Hibernate3
Type: Improvement
Components: core
Environment: MySQL
Reporter: Anthony Patricio
Priority: Minor
Attachments: patch-mysqlDialect.txt
MySQLDialect.getAddForeignKeyConstraintString(String, String[], String, String[], boolean) method is generating also index which is not wanted.
Here is the modified method:
public String getAddForeignKeyConstraintString(
String constraintName,
String[] foreignKey,
String referencedTable,
String[] primaryKey, boolean referencesPrimaryKey
) {
String cols = StringHelper.join(", ", foreignKey);
return new StringBuffer(30)
//.append(" add index ")
//.append(constraintName)
//.append(" (")
//.append(cols)
//.append("), add constraint ")
.append(" add constraint ")
.append(constraintName)
.append(" foreign key (")
.append(cols)
.append(") references ")
.append(referencedTable)
.append(" (")
.append( StringHelper.join(", ", primaryKey) )
.append(')')
.toString();
}
--
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, 9 months
[Hibernate-JIRA] Created: (ANN-551) @SQLInsert. Columns in sql comes in different order depending on the application server used
by Søren Pedersen (JIRA)
@SQLInsert. Columns in sql comes in different order depending on the application server used
--------------------------------------------------------------------------------------------
Key: ANN-551
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-551
Project: Hibernate Annotations
Type: Bug
Components: binder
Versions: 3.2.1
Environment: Hibernate-core 3.2.2, hibernate-annotations 3.2.1. WebLogic 9.2 and JBoss 4.0.5. Oracle 10.
Reporter: Søren Pedersen
Problem:
The columns in the sql you specify in SQLInsert annotation has be ordered in the same way hibernate sorts its properties when constructing the insert sql.
Example:
When WebLogic 9.2 is used the sql should look like this:
"insert into acount (name, address, country) values (?,?,?)"
But when JBoss 4.0.5 is used the sql should look like this:
"insert into acount (address, country, name) values (?,?,?)"
The above are only examples.
Consequence:
I have to have different SQLInsert's for every JEE apllication server we support, because the properties comes in different order depending on the application server used.
Suggested solution:
In the method org.hibernate.cfg.AnnotationBinder.addElementsOfAClass(List<PropertyData> elements, PropertyHolder propertyHolder, boolean isPropertyAnnotated,String propertyAccessor, final XClass annotatedClass, ExtendedMappings mappings)
This property list shown below should be sorted to make sure that the properties also come in the same order:
List<XProperty> properties = annotatedClass.getDeclaredProperties( accessType );
--
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, 9 months
[Hibernate-JIRA] Created: (HHH-2073) many-to-one join fetch with optional parent causing stray query to fire
by Adam Hardy (JIRA)
many-to-one join fetch with optional parent causing stray query to fire
-----------------------------------------------------------------------
Key: HHH-2073
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2073
Project: Hibernate3
Type: Bug
Reporter: Adam Hardy
Priority: Minor
Attachments: bugtest.zip
I have a call centre application which uses a mature database and is therefore pushing Hibernate to accomplish the mappings I need. The issue here is extra queries that Hibernate is firing where I set up the mapping to do a join in one hit.
I am fetching child objects which may or may not have a parent. The child's foreign key points to a non-primary key on the parent. This is not reflected by a foreign key constraint in the database (hence it allows child to have no parent).
If the child object has the foreign key 0 instead of null, which is the protocol in this database, then the parent which doesn't exist is not (& cannot) be instantiated, no problem, but then after processing the resultset, Hibernate fires off another query to fetch the parent that it could not find data for in the first query.
This is obviously unnecessary in this context and degrades the performance on large searches on this child.
I have classified it as minor since I suspect there may be work-arounds but I have not researched that yet.
I didn't know whether I could put the mapping XML in the query, so I have attached a simplistic testcase example that demonstrates the problem.
The following forum messages are relevant and the latter contains the mappings, which is easier than extracting them out of the testcase zip:
http://forum.hibernate.org/viewtopic.php?t=960522
http://forum.hibernate.org/viewtopic.php?t=964211
--
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, 10 months
[Hibernate-JIRA] Created: (HHH-2293) HQL Query with fetch causes exception if no rows selected be query (java.sql.SQLException: Exhausted Resultset )
by Andriy Solonchuk (JIRA)
HQL Query with fetch causes exception if no rows selected be query (java.sql.SQLException: Exhausted Resultset )
----------------------------------------------------------------------------------------------------------------
Key: HHH-2293
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2293
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.2
Environment: Oracle 10g2 (10.2.0.2.0) Hiberbate 3.2.0
Reporter: Andriy Solonchuk
After executing next query
select p from ProductHibernate p left join FETCH p.productSomeCollection
where 1=2 /* that will cause NO rows returned*/
we will have exception
org.hibernate.exception.GenericJDBCException: could not perform sequential read of results (forward)
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
...
Caused by: java.sql.SQLException: Exhausted Resultset
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
...
at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:1088)
at org.hibernate.loader.Loader.loadSequentialRowsForward(Loader.java:375)
... 24 more
If we will review code of Loader.java class we can see next
if ( resultSet.isAfterLast() ) {
// don't even bother trying to read further
return null;
}
if ( resultSet.isBeforeFirst() ) {
resultSet.next();
}
So at this step there are no checking if resultSet has any rows...
--
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
[Hibernate-JIRA] Created: (HHH-2159) Query that previously worked in 3.2.0CR2 does not work anymore
by Andy Dale (JIRA)
Query that previously worked in 3.2.0CR2 does not work anymore
---------------------------------------------------------------
Key: HHH-2159
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2159
Project: Hibernate3
Type: Bug
Versions: 3.2.0.ga
Environment: hibernate 3.2.0GA, PostgreSQL 8.1.4 (using build 407 of the JDBC driver). JDK 1.5.0_06, JBoss 4.0.4GA, Operating system is Fedora Core 5
Reporter: Andy Dale
Attachments: hibernate_testcase.tar.gz
First off i do not know if this bug belongs to the Hibernate3(core) or Hibernate EntityManger branch, but have entered it against core because that is where the exception occurs (in org.hibernate.hql.ast.tree.FromClause.findIntendedAliasedFromElementBasedOnCrazyJPARequirements).
I have a relativley simple entity setup up to test a proof of concept. Persisting the data to the database is not a problem in the new version 3.2.0.GA, but the problems occurs when trying to perform a query on the persisted data, the very same query works with 3.2.0CR2 but gives a nullPointException in 3.2.0GA.
I have attached the java source for the entities + session bean (in hibernate_testcase.tar.gz/entities file) and the java class (in hibernate_testcase.tar.gz/service file) that is used to persist and query the data, and because this was only meant to be a proof of concept i have also included the .ear archive as apart from the entity definitions and session bean the only other thing it contains is a JBoss .sar archive which calls the static persist and query methods in the session bean (service test.testcase). Please note to use the .ear archive you need a datasource called Postgres_Test
--
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
[Hibernate-JIRA] Created: (HHH-2211) A createQuery() caused ORA-00904 error
by sodia (JIRA)
A createQuery() caused ORA-00904 error
--------------------------------------
Key: HHH-2211
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2211
Project: Hibernate3
Type: Bug
Components: query-hql
Versions: 3.2.0.ga
Environment: JDK1.5.0+Eclipse3.2.1+Hibernate3.2.0.ga+Oracle9.2.0+WinXp(Prof)Sp2
Reporter: sodia
Priority: Trivial
Attachments: hiber-grammar-sql-and-errlog.zip, hiber-grammar-test.zip
I want to try the following sql under hibernate,it failed.
(The project is build on the basis of hibernate3.2's tutorial)
String hqlAlias =
"insert into EventHistory ( id, date, title )" +
" select id, date, title from Event e" +
" where e.title like 'BUY%'" +
" and exists" +
" ( select 1 from PersonEvent p" +
" where p.id=e.id)";
int resultAlias = session.createQuery(hqlAlias).executeUpdate();
But it works nice under sqlplus.
INSERT INTO EVENTS_HISTORY
SELECT * FROM EVENTS
WHERE TITLE LIKE 'BUY%'
AND EXISTS
( SELECT 1 FROM PERSON_EVENT
WHERE EVENT_ID=EVENTS.EVENT_ID);
The 4 lines of error log is like this:
15:33:29,906 DEBUG SQL:393 - insert into EVENTS_HISTORY ( EVENT_ID, EVENT_DATE, title ) select event0_.EVENT_ID as col_0_0_, event0_.EVENT_DATE as col_1_0_, event0_.title as col_2_0_ from EVENTS event0_ where (event0_.title like 'BUY%') and (exists (select 1 from PERSON_EVENT personeven1_ where personeven1_.EVENT_ID=EVENTS.EVENT_ID))
Hibernate: insert into EVENTS_HISTORY ( EVENT_ID, EVENT_DATE, title ) select event0_.EVENT_ID as col_0_0_, event0_.EVENT_DATE as col_1_0_, event0_.title as col_2_0_ from EVENTS event0_ where (event0_.title like 'BUY%') and (exists (select 1 from PERSON_EVENT personeven1_ where personeven1_.EVENT_ID=EVENTS.EVENT_ID))
15:33:29,984 WARN JDBCExceptionReporter:71 - SQL Error: 904, SQLState: 42000
15:33:29,984 ERROR JDBCExceptionReporter:72 - ORA-00904: "EVENTS"."EVENT_ID": 无效的??符
Is there any wrong with the hql,or it's alias?
Thanks to anyone who pay attetion to this trivial question which I search the forum and google without solutions.
Or if I missed them,I would be grateful that you might tell me where can I find the right answer to fix this hql grammar error.
--
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, 1 month