[Hibernate-JIRA] Created: (HHH-2022) ORA-00911: invalid character when field begins with underscore
by Jerry Cattell (JIRA)
ORA-00911: invalid character when field begins with underscore
--------------------------------------------------------------
Key: HHH-2022
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2022
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.0.5, 3.1.3, 3.2.0.cr3
Environment: Hibernate 3.1.3
Oracle 10.2.0.1
Reporter: Jerry Cattell
Priority: Minor
Attachments: InvalidCharacterErrorCase.java, SimpleObject.hbm.xml, SimpleObject.java
Hibernate is generating invalid SQL (for Oracle) for collections that are stored in fields with names that start with underscores.
In this SQL:
Hibernate: select _tags0_.SIMPLE_OBJECT_ID as SIMPLE1_0_, _tags0_.TAG as TAG0_ from SIMPLE_OBJECT_TAG _tags0_ where _tags0_.SIMPLE_OBJECT_ID=?
an alias called "_tags0_" is created for the collection table. Unfortunately, Oracle does not allow non-alphabetic characters for the first character in an alias.
Here's the stacktrace:
Hibernate: select _tags0_.SIMPLE_OBJECT_ID as SIMPLE1_0_, _tags0_.TAG as TAG0_ from SIMPLE_OBJECT_TAG _tags0_ where _tags0_.SIMPLE_OBJECT_ID=?
WARN JDBCExceptionReporter 20060822-011120.817 - SQL Error: 911, SQLState: 42000
ERROR JDBCExceptionReporter 20060822-011120.818 - ORA-00911: invalid character
INFO DefaultLoadEventListener 20060822-011120.820 - Error performing load command
org.hibernate.exception.SQLGrammarException: could not initialize a collection: [SimpleObject._tags#1]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1926)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:520)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1676)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:454)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:755)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:229)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:47)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:41)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:161)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:799)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:792)
at InvalidCharacterErrorCase.runTest(InvalidCharacterErrorCase.java:28)
at InvalidCharacterErrorCase.main(InvalidCharacterErrorCase.java:11)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: java.sql.SQLException: ORA-00911: invalid character
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1039)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1132)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1919)
... 26 more
I have attached a test case that causes this error.
After a little bit of research, it appears that a change to StringHelper.generateAlias(String description, int unique) (or StringHelper.generateAliasRoot(String description)) to remove all characters up to the first alphabetic character would solve this 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, 4 months
[Hibernate-JIRA] Created: (HHH-2189) Left Outer Join Conditions
by yann degat (JIRA)
Left Outer Join Conditions
--------------------------
Key: HHH-2189
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2189
Project: Hibernate3
Type: Bug
Components: query-sql
Versions: 3.1.3
Reporter: yann degat
Priority: Blocker
Attachments: OracleJoinFragment.java, OracleJoinFragment.java
the "org.hibernate.sql.OracleJoinFragment.addLeftOuterJoinCondition"
does not take the "!=" operator into account.
it places the "(+)" like this "!(+)=" instead of " (+) !="
( != is a valid operator for Oracle )
and it returns (+)<(+)> for the '<>' operator
here's a patch. (maybe not the best one )
/**
* This method is a bit of a hack, and assumes
* that the column on the "right" side of the
* join appears on the "left" side of the
* operator, which is extremely wierd if this
* was a normal join condition, but is natural
* for a filter.
*/
private void addLeftOuterJoinCondition(String on) {
StringBuffer buf = new StringBuffer( on );
for ( int i = 0; i < buf.length(); i++ ) {
char character = buf.charAt( i );
boolean isInsertPoint = OPERATORS.contains( new Character( character ) ) ||
( character == ' ' && buf.length() > i + 3 && "is ".equals( buf.substring( i + 1, i + 4 ) ) ) ;
if( character == '<' && buf.length() > i + 1 && ">".equals( buf.substring( i + 1, i + 2 ) ) ){
isInsertPoint = false;
buf.insert( i, "(+)" );
i += 3 + 2;
}
if ( isInsertPoint ) {
buf.insert( i, "(+)" );
i += 3;
}
if( character == '!' && buf.length() > i + 1 && "=".equals( buf.substring( i + 1, i + 2 ) ) ){
buf.insert( i, "(+)" );
i += 3 + 2;
}
}
addCondition( buf.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
17 years, 5 months
[Hibernate-JIRA] Created: (HHH-2320) Regression: optional properties under a <join> tag no longer update properly
by Chris Jones (JIRA)
Regression: optional properties under a <join> tag no longer update properly
----------------------------------------------------------------------------
Key: HHH-2320
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2320
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.1, 3.2.0.cr4, 3.2.0.ga, 3.2.0.cr5
Environment: hibernate 3.2.0.cr4 through 3.2.1.ga
hsql 1.8.0.7 and Oracle 9i
Reporter: Chris Jones
This was specifically introduced with the revision 10217 changes on the 3.2 branch in src/org/hibernate/persister/entity/AbstractEntityPersister.java
Given the following setup:
<class name="Thing">
<id .../>
<join table="JOIN_TABLE" optional="true">
<key column="THING_ID" not-null="true"/>
<property name="joinedProperty" column="JOINED_PROPERTY"/>
</join>
</class>
scenario:
Thing thing1 = new Thing();
thing1.setJoinedProperty("thing1");
save(thing1);
// a record in the JOIN_TABLE is created properly and updates on the property can occur
Thing thing2 = new Thing();
thing2.setJoinedProperty(null);
save(thing2);
// no record in JOIN_TABLE is created
thing2.setJoinedProperty("thing2");
save(thing2);
// in revision 10216, hibernate correctly runs an INSERT to create a JOIN_TABLE record with the value "thing2"
// in revision 10217, hibernate incorrectly runs an UPDATE to try and update a non-existant record in the JOIN_TABLE with the thing2 id
It looks like the expectation.verifyOutcome() method should be throwing a StaleStateException if the attempted update effects 0 rows.
I will try and get an official hibernate testcase going and possibly a patch, but I wanted to enter this now in case there is something I'm missing that makes this change in functionality intentional.
--
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-2289) CLONE -Support new MySQL 5.0.12 join syntax
by Peter Lundberg (JIRA)
CLONE -Support new MySQL 5.0.12 join syntax
-------------------------------------------
Key: HHH-2289
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2289
Project: Hibernate3
Type: New Feature
Components: query-sql
Versions: 3.1.2
Reporter: Peter Lundberg
http://dev.mysql.com/doc/refman/5.0/en/join.html
"Beginning with MySQL 5.0.12, natural joins and joins with USING, including outer join variants, are processed according to the SQL:2003 standard. These changes make MySQL more compliant with standard SQL. However, they can result in different output columns for some joins. Also, some queries that appeared to work correctly in older versions must be rewritten to comply with the standard. The following list provides more detail about several effects of the 5.0.12 change in join processing. The term "previously" means "prior to MySQL 5.0.12."
Using 5.0.18 and hibernate 3.1.2, hibernate is not producing the correct join syntax for the latest versions of mysql.
For example:
FROM tableA AS A, tableB AS B INNER JOIN tableC AS C ON A.field1 =
C.field2
The above fails, because the B JOIN C is evaluated before the A alias has
been created.
The solution is to use parentheses to force an order of evaluation:
FROM (tableA AS A, tableB AS B) INNER JOIN tableC AS C ON A.field1 =
C.field2
--
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-2164) Minor bug in section "20.1.1. Customizing the schema"
by Andres Gonzalez (JIRA)
Minor bug in section "20.1.1. Customizing the schema"
-----------------------------------------------------
Key: HHH-2164
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2164
Project: Hibernate3
Type: Bug
Components: documentation
Versions: 3.2.0.ga
Reporter: Andres Gonzalez
Where it says:
*******************************************************************************************************************************
A unique-key attribute may be used to group columns in a single unique key constraint. Currently, the specified value of the unique-key attribute is not used to name the constraint in the generated DDL, only to group the columns in the mapping file.
<many-to-one name="org" column="orgId" unique-key="OrgEmployeeId"/>
<property name="employeeId" unique-key="OrgEmployee"/>
*******************************************************************************************************************************
i think the unique-key attributes should jave both the same value ("OrgEmployee", for example)
--
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-2369) Documentation doesn't state what hibernate returns for empty/null collections
by James Roper (JIRA)
Documentation doesn't state what hibernate returns for empty/null collections
-----------------------------------------------------------------------------
Key: HHH-2369
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2369
Project: Hibernate3
Type: Improvement
Components: documentation
Versions: 3.2.1
Reporter: James Roper
Priority: Trivial
Reading the hibernate documentation, section 6.1:
"Hibernate does not distinguish between a null collection reference and an empty collection"
This is all very well, but what does hibernate return when loading a null/empty collection?
According to the EJB3 specification, section 2.1.7:
"If there are no associated entities for a multi-valued relationship of an entity fetched from the database, the persistence provider is responsible for returning an empty collection as the value of the relationship."
If this is the behavior that hibernate implements, then this should be explicitly stated in the hibernate documentation, so that developers know whether they need to do null checks or not after loading an object from the database.
--
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