[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-1988) Repeated column chack fails with SingleTable inheritance, biut not with TablePerClass
by Sergey Vladimirov (JIRA)
Repeated column chack fails with SingleTable inheritance, biut not with TablePerClass
-------------------------------------------------------------------------------------
Key: HHH-1988
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1988
Project: Hibernate3
Type: Bug
Components: metamodel
Versions: 3.2.0.cr3
Environment: HA last from SVN, HEM last from SVN, MySQL
Reporter: Sergey Vladimirov
Not sure about component.
Parent class introduce field, which is also discriminator field.
Hibernate reports error in child class if and only if strategy = InheritanceType.SINGLE_TABLE
org.hibernate.MappingException: Repeated column in mapping for entity: ru.arptek.arpsite.data.discriminator.IntegerSingleChild column: type (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:590)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:612)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:630)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:405)
at org.hibernate.mapping.SingleTableSubclass.validate(SingleTableSubclass.java:43)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1026)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:631)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:760)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:627)
at ru.arptek.arpsite.data.AbstractHibernateJUnitTest.setUp(AbstractHibernateJUnitTest.java:89)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Test cas works with strategy = InheritanceType.TABLE_PER_CLASS
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-2122) optimization patch based on pmd rules
by Xavier Le Vourch (JIRA)
optimization patch based on pmd rules
-------------------------------------
Key: HHH-2122
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2122
Project: Hibernate3
Type: Patch
Environment: latest svn source
Reporter: Xavier Le Vourch
Priority: Minor
Attachments: Optimizations.patch
I've run pmd with a custom ruleset and made a few optimization changes:
Double.valueOf(x).doubleValue() -> Double.parseDouble(x)
append("x") -> append('x')
x != null && x instanceof X -> x instanceof X
list.toArray uses correctly sized array as argument
new String(str) -> str
if (expr == false) -> if (!expr)
append(s1 + s2) -> append(s1).append(s2)
loop over array to add to list -> list.addAll(Arrays.asList(<array>))
extra ; removed
name.toLowerCase().equals("rowid") -> name.equalsIgnoreCase("rowid")
use of System.arraycopy instead of loop
I could break the patch in several parts if that makes it easier to analyze.
Xavier
--
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, 6 months
[Hibernate-JIRA] Created: (ANN-434) Confusing error message with @EmbeddedId and @Id
by Patrick Moore (JIRA)
Confusing error message with @EmbeddedId and @Id
------------------------------------------------
Key: ANN-434
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-434
Project: Hibernate Annotations
Type: Bug
Versions: 3.2.0.cr1
Environment: Hibernate 3.2.0.cr2
Reporter: Patrick Moore
trying to create an entity with embeddedid and automatically generated ids. The resulting error message was very confusing and may be a bug as well.
(See below for sample files) Notice the message is that TransPolId doesn't have an @Id property when in fact it does. The problem is 'solved' by removing the @Id in the TransPolId class. This caused a lot of wasted time on my part please fix for the next person!
--------------------------------------------------------------------------------
Some additional debugging notes:
The problem is caused in part because when expanding TransPolId to within AnnotationBinder.processElementAnnotations()
isIdentifierMapper == false so none of the checks looking for this sort of thing execute.
I believe the solution is to change AnnotationBinder.bindId() as follows:
(original):
if ( isComposite ) {
id = fillComponent(
propertyHolder, inferredData, isPropertyAnnotated, propertyAccessor,
false, entityBinder, isEmbedded, isIdentifierMapper, mappings
);
Component componentId = (Component) id;
componentId.setKey( true );
if ( componentId.getPropertySpan() == 0 ) {
throw new AnnotationException( componentId.getComponentClassName() + " has no persistent id property" );
}
}
(changed):
if ( isComposite ) {
id = fillComponent(
propertyHolder, inferredData, isPropertyAnnotated, propertyAccessor,
false, entityBinder, isEmbedded, true, mappings <<<<<<<<<<<<<<< isIdentifierMapper replaced by true
);
Component componentId = (Component) id;
componentId.setKey( true );
if ( componentId.getPropertySpan() == 0 ) {
throw new AnnotationException( componentId.getComponentClassName() + " has no persistent id property" );
}
}
Output:
java.vm.name=Java HotSpot(TM) Client VM, cache.provider_class=org.hibernate.cache.NoCacheProvider, file.encoding=Cp1252, java.specification.version=1.5, hibernate.show_sql=true, hibernate.connection.pool_size=1}
16:19:01,109 DEBUG [Configuration] Preparing to build session factory with filters : {}
16:19:01,109 DEBUG [AnnotationConfiguration] Execute first pass mapping processing
16:19:01,109 DEBUG [AnnotationConfiguration] Process hbm files
16:19:01,109 DEBUG [AnnotationConfiguration] Process annotated classes
16:19:01,125 INFO [AnnotationBinder] Binding entity from annotated class: com.transparentpolitics.core.persistence.IdUsing1
16:19:01,125 DEBUG [Ejb3Column] Binding column DTYPE unique false
16:19:01,125 DEBUG [EntityBinder] Import with entity name=IdUsing1
16:19:01,125 INFO [EntityBinder] Bind entity com.transparentpolitics.core.persistence.IdUsing1 on table IdUsing1
16:19:01,125 DEBUG [AnnotationBinder] Processing com.transparentpolitics.core.persistence.IdUsing1 property annotation
16:19:01,125 DEBUG [AnnotationBinder] Processing com.transparentpolitics.core.persistence.IdUsing1 field annotation
16:19:01,125 DEBUG [AnnotationBinder] Processing annotations of com.transparentpolitics.core.persistence.IdUsing1.transid
16:19:01,125 DEBUG [Ejb3Column] Binding column transid unique false
16:19:01,125 DEBUG [AnnotationBinder] transid is an id
16:19:01,125 DEBUG [AnnotationBinder] Binding component with path: com.transparentpolitics.core.persistence.IdUsing1.transid
16:19:01,125 DEBUG [AnnotationBinder] Processing com.transparentpolitics.core.persistence.TransPolId field annotation
16:19:01,125 DEBUG [AnnotationBinder] Processing annotations of com.transparentpolitics.core.persistence.TransPolId.id
16:19:01,125 DEBUG [Ejb3Column] Binding column id unique false
16:19:01,125 DEBUG [AnnotationBinder] id is an id
16:19:01,125 DEBUG [SimpleValueBinder] building SimpleValue for id
16:19:01,125 DEBUG [PropertyBinder] Building property id
16:19:01,125 DEBUG [PropertyBinder] Cascading id with null
16:19:01,125 DEBUG [AnnotationBinder] Bind @Id on id
org.hibernate.AnnotationException: com.transparentpolitics.core.persistence.TransPolId has no persistent id property
at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1686)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1170)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:699)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:353)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:265)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:682)
... 20 more
@Embeddable
public class TransPolId implements Serializable {
@Id @GeneratedValue
public Long id;
@Override
public boolean equals(Object o) {
if ( o instanceof TransPolId ) {
return ((TransPolId)o).id.equals(id);
}
return false;
}
@Override
public int hashCode() {
return id.hashCode();
}
}
@Entity
public class IdUsing1 {
@EmbeddedId
public TransPolId id;
public String value;
}
--
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, 6 months
[Hibernate-JIRA] Created: (ANN-430) @ManyToOne results in default outer join eager fetch, should be lazy
by Christian Bauer (JIRA)
@ManyToOne results in default outer join eager fetch, should be lazy
--------------------------------------------------------------------
Key: ANN-430
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-430
Project: Hibernate Annotations
Type: Bug
Components: documentation, binder
Reporter: Christian Bauer
Documentation says:
<sect3>
<title>Association fetching</title>
<para>You have the ability to either eagerly or lazily fetch
associated entities. The <literal>fetch</literal> parameter can be set
to <literal>FetchType.LAZY</literal> or
<literal>FetchType.EAGER</literal>. <literal>EAGER</literal> will try
to use an outer join select to retrieve the associated object, while
<literal>LAZY</literal> is the default and will only trigger a select
when the associated object is accessed for the first time. EJBQL also
has a <literal>fetch</literal> keyword that allows you to override
laziness when doing a particular query. This is very useful to improve
performance and is decided on a use case to use case basis.</para>
</sect3>
However, a simple @ManyToOne without any other attributes results in an eager join outer fetch.
--
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, 7 months