[Hibernate-JIRA] Commented: (HHH-1131) setting classloader in CGLIB class generators
by Moshe Ben Shoham (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1131?page=c... ]
Moshe Ben Shoham commented on HHH-1131:
---------------------------------------
the current thread classloader when CGLIB loads is not the coorect one to use because I dynamically create a classloader that contains JARs that are not in the classpath after CGLIB loads. Those JARs contain HBM files as well as the Java domain classes. This is the classloader I would like to use.
> 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
18 years, 3 months
[Hibernate-JIRA] Created: (HBX-980) org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class=
by Matt Braunwart (JIRA)
org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class=
------------------------------------------------------------------------------------------------------
Key: HBX-980
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-980
Project: Hibernate Tools
Issue Type: Bug
Components: eclipse
Affects Versions: 3.2beta7
Environment: Hibernate 3.2 latest, Hibernate Tools 3.2.0, Eclipse 3.3.0
Reporter: Matt Braunwart
I am having an issue with getting the session factory. I have searched and searched for anything referring to this, and the results i find are nothing like the error that I am receiving. If anyone could assist me with this problem, I will be very grateful.
Problem while executing Create SessionFactory(An AnnotationConfiguration instance is required to use <mapping class="movieblends.beans.Tagsuggestions"/>)
org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="movieblends.beans.Tagsuggestions"/>
An AnnotationConfiguration instance is required to use <mapping class="movieblends.beans.Tagsuggestions"/>
org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="movieblends.beans.Tagsuggestions"/>
An AnnotationConfiguration instance is required to use <mapping class="movieblends.beans.Tagsuggestions"/>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Aug 22, 2007 2:31:06 PM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="movieblends.beans.Tagsuggestions" table="tagsuggestions" catalog="mbadmins">
<comment></comment>
<id name="messageId" type="int">
<column name="messageID" />
<generator class="assigned" />
</id>
<many-to-one name="user" class="movieblends.beans.User" fetch="select">
<column name="userID" not-null="true">
<comment></comment>
</column>
</many-to-one>
<property name="suggestion" type="string">
<column name="suggestion" not-null="true">
<comment></comment>
</column>
</property>
</class>
</hibernate-mapping>
package movieblends.beans;
// Generated Aug 22, 2007 2:31:06 PM by Hibernate Tools 3.2.0.b9
import java.util.List;
import javax.naming.InitialContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Example;
/**
* Home object for domain model class Tagsuggestions.
* @see movieblends.beans.Tagsuggestions
* @author Hibernate Tools
*/
public class TagsuggestionsHome {
private static final Log log = LogFactory.getLog(TagsuggestionsHome.class);
private final SessionFactory sessionFactory = getSessionFactory();
protected SessionFactory getSessionFactory() {
try {
return (SessionFactory) new InitialContext().lookup("SessionFactory");
} catch (Exception e) {
log.error("Could not locate SessionFactory in JNDI", e);
throw new IllegalStateException("Could not locate SessionFactory in JNDI");
}
}
public void persist(Tagsuggestions transientInstance) {
log.debug("persisting Tagsuggestions instance");
try {
sessionFactory.getCurrentSession().persist(transientInstance);
log.debug("persist successful");
} catch (RuntimeException re) {
log.error("persist failed", re);
throw re;
}
}
public void attachDirty(Tagsuggestions instance) {
log.debug("attaching dirty Tagsuggestions instance");
try {
sessionFactory.getCurrentSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Tagsuggestions instance) {
log.debug("attaching clean Tagsuggestions instance");
try {
sessionFactory.getCurrentSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void delete(Tagsuggestions persistentInstance) {
log.debug("deleting Tagsuggestions instance");
try {
sessionFactory.getCurrentSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Tagsuggestions merge(Tagsuggestions detachedInstance) {
log.debug("merging Tagsuggestions instance");
try {
Tagsuggestions result = (Tagsuggestions) sessionFactory.getCurrentSession().merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public Tagsuggestions findById(int id) {
log.debug("getting Tagsuggestions instance with id: " + id);
try {
Tagsuggestions instance = (Tagsuggestions) sessionFactory.getCurrentSession().get(
"movieblends.beans.Tagsuggestions", id);
if (instance == null) {
log.debug("get successful, no instance found");
} else {
log.debug("get successful, instance found");
}
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Tagsuggestions instance) {
log.debug("finding Tagsuggestions instance by example");
try {
List results = sessionFactory.getCurrentSession().createCriteria("movieblends.beans.Tagsuggestions").add(
Example.create(instance)).list();
log.debug("find by example successful, result size: " + results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
}
package movieblends.beans;
// Generated Aug 22, 2007 2:31:06 PM by Hibernate Tools 3.2.0.b9
/**
* Tagsuggestions generated by hbm2java
*/
public class Tagsuggestions implements java.io.Serializable {
private int messageId;
private User user;
private String suggestion;
public Tagsuggestions() {
}
public Tagsuggestions(int messageId, User user, String suggestion) {
this.messageId = messageId;
this.user = user;
this.suggestion = suggestion;
}
public int getMessageId() {
return this.messageId;
}
public void setMessageId(int messageId) {
this.messageId = messageId;
}
public User getUser() {
return this.user;
}
public void setUser(User user) {
this.user = user;
}
public String getSuggestion() {
return this.suggestion;
}
public void setSuggestion(String suggestion) {
this.suggestion = suggestion;
}
}
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="mbdb">
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/mbadmins</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<mapping class="movieblends.beans.Tagsuggestions" />
<mapping class="movieblends.beans.Review" />
<mapping class="movieblends.beans.Posts" />
<mapping class="movieblends.beans.Tags" />
<mapping class="movieblends.beans.Movie" />
<mapping class="movieblends.beans.Ratings" />
<mapping class="movieblends.beans.User" />
<mapping class="movieblends.beans.Threads" />
<mapping class="movieblends.beans.Profile" />
</session-factory>
</hibernate-configuration>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering>
<table-filter match-catalog="mbadmins" match-name="keywords"/>
<table-filter match-catalog="mbadmins" match-name="movie"/>
<table-filter match-catalog="mbadmins" match-name="posts"/>
<table-filter match-catalog="mbadmins" match-name="profile"/>
<table-filter match-catalog="mbadmins" match-name="ratings"/>
<table-filter match-catalog="mbadmins" match-name="review"/>
<table-filter match-catalog="mbadmins" match-name="tags"/>
<table-filter match-catalog="mbadmins" match-name="tagsuggestions"/>
<table-filter match-catalog="mbadmins" match-name="threads"/>
<table-filter match-catalog="mbadmins" match-name="user"/>
</hibernate-reverse-engineering>
There is some information on what I have done so far.
--
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
18 years, 3 months
[Hibernate-JIRA] Commented: (HHH-1123) Cannot put more than 1000 elements in a InExpression
by Tom Schneider (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1123?page=c... ]
Tom Schneider commented on HHH-1123:
------------------------------------
I'm not sure the above solution will work for all cases in Oracle. I think after 2000 elements in the where clause it will error out. (I have to test this to verify) Is there anyway to execute more than 1 sql statement in a single criteria? The solution we typically use is to break the query into multiple queries and merge the results. Otherwise the in clause has to be broken up outside of Hibernate.
> Cannot put more than 1000 elements in a InExpression
> ----------------------------------------------------
>
> Key: HHH-1123
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1123
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1 rc2, 3.2.0.alpha1
> Environment: Oracle 9i
> Reporter: Alexis Seigneurin
> Attachments: patch.txt
>
> Original Estimate: 1 hour
> Remaining Estimate: 1 hour
>
> The number of elements that we can put in a "in" expression is limited to a certain amount (1000 for Oracle, for instance). When creating a criteria query, the org.hibernate.criterion.InExpression class should split the expression into several smaller ones.
> Attached is a patch which splits the expression by slices of 500 elements. For example, if we have 1001 elements to put in the "in" expression, the result would be :
> (entity.field in (?, ?, ?...) or entity.field in (?, ?, ?...) or entity.field in (?))
> The surrounding parantheses are useful to avoid problems with other conditions (a "and" condition taking over the one of the "or" conditions).
--
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
18 years, 3 months
[Hibernate-JIRA] Created: (HBX-946) Add a general meta for all the tables in the database, see [HBX-575]
by Hashim Kubba (JIRA)
Add a general meta for all the tables in the database, see [HBX-575]
--------------------------------------------------------------------
Key: HBX-946
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-946
Project: Hibernate Tools
Issue Type: Improvement
Components: reverse-engineer
Affects Versions: 3.2beta9
Environment: using eclipse 3.2.2
JDK 1.5
hibernate tools 3.2beta9
h2 database ver 1.0
Reporter: Hashim Kubba
Priority: Minor
I'm adding meta attributes in reveng.xml (HBX-575) for customization of the resulting Java code from a reverse engineered database. yet I would really like to be able to add a general class-description to all my classes ( say @ Auther or @version ) , even better; I want all my classes to extend BasicDataObject where I can add some static final constants to use, but now I have to add that to each table
<hibernate-reverse-engineering>
<table name="FOO">
<meta attribute="extends">BasicDataObject</meta>
</table name>
<table name="BOO">
<meta attribute="extends">BasicDataObject</meta>
</table name>
...
</hibernate-reverse-engineering>
What I would like to see is something like
<hibernate-reverse-engineering>
<meta attribute="extends">BasicDataObject</meta>
</hibernate-reverse-engineering>
and that will make all my classes extend BasicDataObject; metas that can be used directly under hibernate-reverse-engineering are:
* class-description general comment for all classes
* implements implements a common interface with constants
* extends extends a common class with constants and common methods
* scope-class make all classes protected
* scope-set all sets in all classes
* scope-get all gets in all classes
A nice to have will be:
* generated-class-suffix
* generated-class-prefix
or <meta name="generated-class" suffix="suffix" prefix="prefix" />
that will allow me to control all the classes names
--
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
18 years, 3 months
[Hibernate-JIRA] Created: (HBX-986) <meta attribute="scope-field">protected</meta> does not work
by Tao Liu (JIRA)
<meta attribute="scope-field">protected</meta> does not work
------------------------------------------------------------
Key: HBX-986
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-986
Project: Hibernate Tools
Issue Type: Bug
Components: reverse-engineer
Environment: Oracle 9i, Eclipse 3.2
Reporter: Tao Liu
The table is as below.
CREATE TABLE SVW.table1 (
col1 CHAR(3) NOT NULL,
col2 NUMBER,
col3 VARCHAR(28) NOT NULL,
PRIMARY KEY(col1) );
My reveng.xml is
<hibernate-reverse-engineering>
<table-filter match-schema="SVW" match-name="TAB.*">
<meta attribute="extra-import">ep.base.data.po.BasePO</meta>
<meta attribute="extends">BasePO</meta>
<meta attribute="scope-field">protected</meta>
</table-filter>
</hibernate-reverse-engineering>
When I generate code with annotations from Oracle 9i, the result is as below. The filed is still private.
package acl;
// Generated 2007-9-11 19:14:17 by Hibernate Tools 3.2.0.b9
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.SEQUENCE;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
/**
* Table1 generated by hbm2java
*/
@Entity
@Table(name = "TABLE1", schema = "SVW")
public class Table1 implements java.io.Serializable {
private String col1;
private BigDecimal col2;
private String col3;
public Table1() {
}
public Table1(String col3) {
this.col3 = col3;
}
public Table1(BigDecimal col2, String col3) {
this.col2 = col2;
this.col3 = col3;
}
@SequenceGenerator(name = "generator", sequenceName = "TABLE1_ID_SEQ1")
@Id
@GeneratedValue(strategy = SEQUENCE, generator = "generator")
@Column(name = "COL1", unique = true, nullable = false, length = 3)
public String getCol1() {
return this.col1;
}
public void setCol1(String col1) {
this.col1 = col1;
}
@Column(name = "COL2", precision = 22, scale = 0)
public BigDecimal getCol2() {
return this.col2;
}
public void setCol2(BigDecimal col2) {
this.col2 = col2;
}
@Column(name = "COL3", nullable = false, length = 28)
public String getCol3() {
return this.col3;
}
public void setCol3(String col3) {
this.col3 = col3;
}
}
--
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
18 years, 3 months