[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
16 years, 8 months
[Hibernate-JIRA] Created: (HHH-2825) In the HibernateService (JMX) create support for annotated classes
by Marco Tedone (JIRA)
In the HibernateService (JMX) create support for annotated classes
------------------------------------------------------------------
Key: HHH-2825
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2825
Project: Hibernate3
Issue Type: New Feature
Components: core
Affects Versions: 3.2.5
Reporter: Marco Tedone
Attachments: ConfigurationFactory.java, ExternalSessionFactoryConfig.java, HibernateService.java, HibernateServiceMBean.java
Hi, I was faced with the problem of declaring an HB SessionFactory as a JMX service (using the HibernateService class) but I was impossibilitated from declaring mapped classes. Basically as it stands at the moment, the HibernateService MBean allows only to specify a mapResources property which is a comma separated list of .hbm.xml files. I changed the current service in order to allow another property (mappedClasses) which allows a comma separated list of @Entity classes which are loaded and mapped at runtime. It would be nice if this change would be included in future versions of Hibernate. This change involved the following:
1) To add two extra methods in the org.hibernate.jmx.HibernateServiceMBean interface (getter/setter for the new property)
2) To add another String attribute to org.hibernate.util.ExternalSessionFactoryConfig to contain the additional property
3) To create a new ConfigurationFactory class which creates standard configurations (Configuration) or configurations which support annotations (AnnotationConfiguration) depending if the new property contains any values (this property is mutually exclusive with the mapResources one)
The drawback is that AnnotationConfiguration is part of the hibernate-annotations artifact, so in order for this change to work, hibernate-annotations should be included in the hibernate/lib folder, introducing a dependency that maybe is unwanted. If you guys find a better way, feel free to change things around
As I said it would be nice to have this feature in the next HB release, so I'm happy to post/attach the code I've changed, just let me know how could I do that.
--
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, 8 months
[Hibernate-JIRA] Created: (HSHARDS-46) ShardedSessionImpl.isOpen() is inconsistent with SessionImpl.isOpen()
by Max Ross (JIRA)
ShardedSessionImpl.isOpen() is inconsistent with SessionImpl.isOpen()
---------------------------------------------------------------------
Key: HSHARDS-46
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSHARDS-46
Project: Hibernate Shards
Issue Type: Bug
Components: engine
Reporter: Max Ross
Assignee: Max Ross
Fix For: 3.0.0
Email exchange between Aviad and Max:
Aviad:
I am working on using a Spring SessionFatoryBean class, so the Shard Session can be integrated correctly with the Spring TrasnsactionManager (not distributed transactions) and the OpenSessionInViewFilter.
While debugging this issue, we encountered that the isOpen method of the ShardedSessionImpl is not acting as the hibernate session version.
In hibernate if a session is not closed then it is open, meaning every created session that wasn't closed is treated as open.
In the Shard implementation the method looks for an open HibernateSession in order to return 'true'. This issue causes an unexpected behavior with Spring Transactions, so unless there is an unseen reason for this implementation I suggest to change the method isOpen to return true as long as the session wasn't closed.
Max:
Great, I'm glad to hear you're making progress. I think I understand the issue with isOpen but let me just make sure. The problem in Shards is that a ShardedSession is only considered open if it contains at least one open Session. Since we don't open Sessions until someone performs an operation on the ShardedSession that actually requires a Session, if you create a new ShardedSession and immediately call isOpen() it will return false, whereas if you create a regular Session and immediately call isOpen() it will return true. If I understand the problem correctly that makes sense I can submit the change.
Aviad:
About the problem we discussed you did understand correctly, and I will be glad if it will be changed.
--
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, 8 months
[Hibernate-JIRA] Created: (HSHARDS-9) Add ShardAware interface and related exit strategy logic
by Nathan Silberman (JIRA)
Add ShardAware interface and related exit strategy logic
--------------------------------------------------------
Key: HSHARDS-9
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSHARDS-9
Project: Hibernate Shards
Issue Type: New Feature
Components: strategy
Affects Versions: 3.0.0.Beta1
Environment: Hibernate 3.2, Database: DB2
Reporter: Nathan Silberman
Assignee: Max Ross
Domain model awareness of its host Shard. Any domain model that implemented a 'ShardAware' interface would contain a Set<ShardId> that could be injected by the relevant ExitStrategy.
This could be solved by adding the following interface:
-------------------------------------------------------
package org.hibernate.shards;
import org.hibernate.shards.ShardId;
import java.util.Set;
/**
* Interface for persistent objects that are aware of the virtual shardIds
* that host them.
*/
public interface ShardAware {
/**
* Sets the virtual ShardIds that host the implementing
* persistant object
*
* @param shardid
* a non-null, non-empty Set of ShardIds
* @throws IllegalArgumentException
* if <tt>shardIds</tt> is null or empty
*/
void setShardIds( Set<ShardId> shardids );
}
---------------------------------------------------
An simple exit strategy that could be used, for example, would set the ShardIds for each resulting ShardAware domain model:
------------------------------------------------------
package org.hibernate.shards.strategy.exit;
import java.util.List;
import org.hibernate.shards.Shard;
import org.hibernate.shards.ShardAware;
/**
* ShardAwareConcatenateListsExistStrategy sets the ShardIds on each of the given
* objects returned by each Shard.
*
* One should be aware that usage of this class adds O(n) overhead to each retrieval
* as the setting of each ShardIds Set is invoked by iterating over the entire resultSet.
*/
public class ShardAwareConcatenateListsExistStrategy extends ConcatenateListsExitStrategy {
@Override
public synchronized boolean addResult(List<Object> oneResult, Shard shard ) {
if ( oneResult != null && ! oneResult.isEmpty()
&& oneResult.get( 0 ) instanceof ShardAware ) {
for( Object object : oneResult ) {
((ShardAware)object).setShardIds( shard.getShardIds() );
}
}
return super.addResult( oneResult, shard );
}
}
---------------------------------------
This change might require changes wherever ShardAccessStrategy.apply() could be invoked.
I have made the changes including a small alteration to the ShardedCriteriaImpl, to use ShardAwareConcatenateListsExistStrategy instead of ConcatenateListsExitStrategy, with success.
--
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, 8 months
[Hibernate-JIRA] Commented: (HHH-1131) setting classloader in CGLIB class generators
by Bart den Haak (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1131?page=c... ]
Bart den Haak commented on HHH-1131:
------------------------------------
This fix really works for me too! I'm using OSGi technolgy (dynamic loading) and with this fix it will work. This without putting the default-lazy='false' attribute on my <hibernate-mapping> element. Also very handy when using HyperJAXB3 (with hibernate annotations).
This is my fix for hibernate core 3.2.1GA. Just replace the CGLIBLazyInitializer.getProxyFactory() method in the the package org/hibernate/proxy/pojo/cglib/CGLIBLazyInitializer.java (see SVN http://anonsvn.jboss.org/repos) by this one. You could compile this class by yourself (with hibernate core in your classpath) and override the class file in the hibernate-3.2.1GA.jar.
public static Class getProxyFactory(Class persistentClass, Class[] interfaces)
throws HibernateException {
Enhancer e = new Enhancer();
e.setSuperclass( interfaces.length == 1 ? persistentClass : null );
e.setInterfaces(interfaces);
e.setCallbackTypes(new Class[]{
InvocationHandler.class,
NoOp.class,
});
e.setCallbackFilter(FINALIZE_FILTER);
e.setUseFactory(false);
e.setInterceptDuringConstruction( false );
ClassLoader classLoader = null;
// -- -FIX STARTS HERE ---
try {
classLoader = Class.forName("org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer").getClassLoader();
}
catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
if(classLoader == null){
e.setClassLoader(Thread.currentThread().getContextClassLoader());
System.out.println("--> USING currentThread classloader");
}
else{
e.setClassLoader( classLoader );
System.out.println("--> USING org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer classloader");
}
// --- FIX END ---
return e.createClass();
}
> setting classloader in CGLIB class generators
> ---------------------------------------------
>
> Key: HHH-1131
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1131
> Project: Hibernate3
> Issue Type: Improvement
> Components: core
> Affects Versions: 3.0.5
> Environment: Hibernate 3.0.5, Oracle 10
> Reporter: Moshe Ben Shoham
>
> In my application I am loading plug-ins mapping documents and persistent classes from jars using some UrlClassLoaders (one per plugin). I then set the threadContextClassLoader to be the CompositeClassLoader that holds all those UrlClassLoaders. Everything works fine until I add a proxy to one of the mapping document (I simplified the names a little):
> <hibernate-mapping>
> <subclass
> name="myplugin.MyExtension"
> discriminator-value="3"
> proxy="myplugin.IMyExtension"
> extends="core.MyBasicClass"
> >
> <join table="MY_EXTENSION">
> <key column="ENTITY_ID"/>
> <property name="extraNumData" column="EXTRA_NUM_DATA" type="long"/>
> <property name="extraStrData" column="EXTRA_STR_DATA" type="string"/>
> </join>
> </subclass >
> </hibernate-mapping>
> See below the exception I get.
> Hibernate uses net.sf.cglib.proxy.Enhancer as the class generator in CGLIBLazyInitializer.getProxyFactory(). Now, it seeme like CGLIB allows customizing the ClassLoader used by its class generators using the method net.sf.cglib.core.AbstractClassGenerator.setClassLoader() (Enhancer extends AbstractClassGenerator). But, it doesn't seem like it is possible to use it in Hibernate, because this is how the Enhancer is used in CGLIBLazyInitializer.getProxyFactory() :
> return (Factory) Enhancer.create(
> (interfaces.length==1) ? persistentClass : null,
> interfaces,
> NULL_METHOD_INTERCEPTOR
> );
> If I replace it with the following code, it works:
> Enhancer e = new Enhancer();
> e.setSuperclass((interfaces.length==1) ? persistentClass : null);
> e.setInterfaces(interfaces);
> e.setCallback(NULL_METHOD_INTERCEPTOR);
> e.setClassLoader(Thread.currentThread().getContextClassLoader()); // this is the addition!
> return (Factory)e.create();
> Is there any other way I can do it (I know I can implement my own persister, but it seems like there's too much code that needs to be overridden...)?
> Is there any planned enhancement regarding this issue?
> Full stack trace of any exception that occurs:
> CGLIB Enhancement failed: com.octavian.fas.domain.business.BusinessTransaction
> net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
> at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:236)
> at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:373)
> at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:281)
> at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:640)
> at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:94)
> at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:42)
> at org.hibernate.tuple.PojoTuplizer.buildProxyFactory(PojoTuplizer.java:144)
> at org.hibernate.tuple.AbstractTuplizer.<init>(AbstractTuplizer.java:83)
> at org.hibernate.tuple.PojoTuplizer.<init>(PojoTuplizer.java:54)
> at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:47)
> at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:218)
> at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400)
> at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104)
> at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
> at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:211)
> at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
> at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:777)
> at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:703)
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1058)
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:363)
> at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
> at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
> at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:269)
> at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:318)
> at com.octavian.sma.analytical.batch.SpringHelper.init(SpringHelper.java:77)
> at com.octavian.sma.analytical.batch.SpringHelper.<init>(SpringHelper.java:38)
> at com.octavian.sma.analytical.batch.dailynongrouping.DailyNonGroupingAnalyticalBatch.initSpringHelper(DailyNonGroupingAnalyticalBatch.java:44)
> at com.octavian.sma.analytical.batch.AnalyticalBatch.run(AnalyticalBatch.java:58)
> at com.octavian.sma.analytical.batch.dailynongrouping.DailyNonGroupingAnalyticalBatch.main(DailyNonGroupingAnalyticalBatch.java:29)
> Caused by: java.lang.reflect.InvocationTargetException
> at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:373)
> at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:218)
> ... 28 more
> Caused by: java.lang.NoClassDefFoundError: myplugin/IMyBusinessTransactionExtension
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> ... 33 more
--
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, 8 months