[Hibernate-JIRA] Created: (HHH-2697) Can't use := for variable assignment within a SQL-Statement
by Benjamin Gniza (JIRA)
Can't use := for variable assignment within a SQL-Statement
-----------------------------------------------------------
Key: HHH-2697
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2697
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.4.sp1
Environment: MySQL Datasource, Hibernate 3.2.4.sp1
Reporter: Benjamin Gniza
Priority: Minor
i found a kind of bug in org.hibernate.engine.query.ParameterParser.java:
I have an exotic mysql-statement where I want to use mysql variables.
VERY SIMPLE example:
SET @pos=0;
SELECT @pos:=@pos+1 FROM TABLE;
Steps to reproduce:
Session s = sessionFactory.openSession();
s.createSQLQuery("SET @pos=0").executeUpdate();
SQLQuery qry = s.createSQLQuery("select @pos:=@pos from SomeTable");
List lst = qry.list();
Exception:
org.hibernate.QueryException: Space is not allowed after parameter prefix ':' 'SELECT @pos:=@pos+1 FROM TABLE'
at org.hibernate.engine.query.ParameterParser.parse(ParameterParser.java:68)
...
...
Suggested fix:
ParameterParser Lines 62 to 73:
if (c == ':' && (indx + 1 >= stringLength || sqlString.charAt(indx + 1) != '=')) {
// named parameter
int right = StringHelper.firstIndexOfChar( sqlString, ParserHelper.HQL_SEPARATORS, indx + 1 );
int chopLocation = right < 0 ? sqlString.length() : right;
String param = sqlString.substring( indx + 1, chopLocation );
if ( StringHelper.isEmpty( param ) ) {
throw new QueryException("Space is not allowed after parameter prefix ':' '"
+ sqlString + "'");
}
recognizer.namedParameter( param, indx );
indx = chopLocation - 1;
}
--
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
12 years, 2 months
[Hibernate-JIRA] Created: (HHH-2165) Change logging level in TableMetadata from INFO to DEBUG or TRACE
by Igor A Tarasov (JIRA)
Change logging level in TableMetadata from INFO to DEBUG or TRACE
-----------------------------------------------------------------
Key: HHH-2165
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2165
Project: Hibernate3
Type: Improvement
Components: metamodel
Versions: 3.2.0.ga
Reporter: Igor A Tarasov
TableMetadata produce too many output to INFO log level. It good thing if it output be at DEBUG level to not hide other impotant information as service start/stop and other.
20.10.06 18:01:58 INFO [main]: SchemaUpdate - updating schema
20.10.06 18:01:58 INFO [main]: TableMetadata - table found: isp.ChageDO
20.10.06 18:01:58 INFO [main]: TableMetadata - columns: [id, _version, chagedate, created, service, sum, restbalance, comment, customer_id]
20.10.06 18:01:58 INFO [main]: TableMetadata - foreign keys: []
20.10.06 18:01:58 INFO [main]: TableMetadata - indexes: [id, fk8f40c06527214c11, chagedate, primary]
20.10.06 18:01:58 INFO [main]: TableMetadata - table found: isp.CustomerDO
20.10.06 18:01:58 INFO [main]: TableMetadata - columns: [phone, firm, group_id, deleted, fio, id, balance, created, updated, address, email, name, comment]
20.10.06 18:01:58 INFO [main]: TableMetadata - foreign keys: []
20.10.06 18:01:58 INFO [main]: TableMetadata - indexes: [id, primary, fk1892e50924b4a799, deleted]
20.10.06 18:01:58 INFO [main]: TableMetadata - table found: isp.GroupDO
20.10.06 18:01:58 INFO [main]: TableMetadata - columns: [id, updated, created, name, comment, deleted]
20.10.06 18:01:58 INFO [main]: TableMetadata - foreign keys: []
20.10.06 18:01:58 INFO [main]: TableMetadata - indexes: [id, primary, deleted]
20.10.06 18:01:58 INFO [main]: TableMetadata - table found: isp.HostDO
20.10.06 18:01:58 INFO [main]: TableMetadata - columns: [tarif_id, server_id, ips, mac, deleted, id, created, updated, name, lastactive, comment, disabled, customer_id]
20.10.06 18:01:58 INFO [main]: TableMetadata - foreign keys: []
20.10.06 18:01:58 INFO [main]: TableMetadata - indexes: [ips, name, primary, fk812f2053f280a3b1, mac, deleted, fk812f205327214c11, fk812f20537f1e2ff9]
20.10.06 18:01:58 INFO [main]: TableMetadata - table found: isp.HostSessionDO
20.10.06 18:01:58 INFO [main]: TableMetadata - columns: [id, host_id, starttime, chage, speedou, updatetime, speedin, bytesin, stoptime, bytesou, version]
20.10.06 18:01:58 INFO [main]: TableMetadata - foreign keys: []
20.10.06 18:01:58 INFO [main]: TableMetadata - indexes: [fk9a9074b995d39b51, id, primary]
20.10.06 18:01:58 INFO [main]: TableMetadata - table found: isp.LoginDO
20.10.06 18:01:58 INFO [main]: TableMetadata - columns: [id, nickname, updated, created, name, comment, password, deleted, customer_id, disabled]
20.10.06 18:01:58 INFO [main]: TableMetadata - foreign keys: []
20.10.06 18:01:58 INFO [main]: TableMetadata - indexes: [id, name, primary, fk77a0599427214c11, deleted]
20.10.06 18:01:58 INFO [main]: TableMetadata - table found: isp.PPPAccountDO
20.10.06 18:01:58 INFO [main]: TableMetadata - columns: [tarif_id, login_id, id, server_id, updated, created, comment, deleted, disabled, ip]
20.10.06 18:01:58 INFO [main]: TableMetadata - foreign keys: []
20.10.06 18:01:58 INFO [main]: TableMetadata - indexes: [id, fk507abf087f1e2ff9, primary, fk507abf08f280a3b1, fk507abf08820174d9, deleted]
20.10.06 18:01:58 INFO [main]: TableMetadata - table found: isp.PPPSessionDO
20.10.06 18:01:58 INFO [main]: TableMetadata - columns: [callerid, starttime, account_id, updatetime, speedou, chage, speedin, stoptime, bytesou, version, ip, id, ident, bytesin]
20.10.06 18:01:58 INFO [main]: TableMetadata - foreign keys: []
20.10.06 18:01:58 INFO [main]: TableMetadata - indexes: [id, fke19b413144f3fa61, starttime, ident, updatetime, primary, stoptime]
20.10.06 18:01:58 INFO [main]: TableMetadata - table found: isp.PaymentDO
20.10.06 18:01:58 INFO [main]: TableMetadata - columns: [id, _version, created, nalichka, sum, paydate, comment, newbalance, customer_id]
20.10.06 18:01:58 INFO [main]: TableMetadata - foreign keys: []
20.10.06 18:01:58 INFO [main]: TableMetadata - indexes: [id, fk7249f0f127214c11, primary, paydate]
20.10.06 18:01:58 INFO [main]: TableMetadata - table found: isp.ServerDO
20.10.06 18:01:58 INFO [main]: TableMetadata - columns: [id, updated, created, name, comment, deleted, ip]
20.10.06 18:01:58 INFO [main]: TableMetadata - foreign keys: []
20.10.06 18:01:58 INFO [main]: TableMetadata - indexes: [id, name, primary, deleted, ip]
20.10.06 18:01:58 INFO [main]: TableMetadata - table found: isp.TarifDO
20.10.06 18:01:58 INFO [main]: TableMetadata - columns: [costsizein, resetprepaidsize, prepaidsizerest, moncost, resetprepaidusages, costusage, resetprepaidtime, deleted, prepaidtimemonthly, costtime, prepaidsizemonthly, id, prepaidusagesrest, monthenddate, costsizeou, created, updated, name, prepaidtimerest, prepaidusagesmonthly, comment, customer_id]
20.10.06 18:01:58 INFO [main]: TableMetadata - foreign keys: []
20.10.06 18:01:58 INFO [main]: TableMetadata - indexes: [id, primary, fk7893f6d27214c11, deleted]
20.10.06 18:01:58 INFO [main]: SchemaUpdate - schema update complete
--
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
12 years, 2 months
[Hibernate-JIRA] Created: (HBX-978) unique=true attribute of primary key in generated class prevents the schema to be regenerated
by Ali Sadik Kumlali (JIRA)
unique=true attribute of primary key in generated class prevents the schema to be regenerated
---------------------------------------------------------------------------------------------
Key: HBX-978
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-978
Project: Hibernate Tools
Issue Type: Bug
Environment: OS: Windows Vista 6.0,x86
Database: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
Java VM: Java HotSpot(TM) Server VM 1.5.0_11-b03,Sun Microsystems Inc.
Eclipse Europa: Version: 3.3.0 Build id: I20070621-1340
HibernateTools-3.2.0.beta10
Reporter: Ali Sadik Kumlali
Priority: Minor
Hi,
When I reverse engineer against Oracle, unique=true attribute is added to @Column annotation of primary key column. But, when I generate schema from these generated files, Oracle throws "ORA-02261: such unique or primary key already exists in the table" error.
I first ran into this situation while trying Seam and posted the problem to Seam's forum: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=116478. After I got the response, decided to try it without Seam. Then, downloaded the latest HibernateTools & Eclipse Europa and reverse engineered the schema. I saw that generated classes have unique=true attribute which clearly showed that the problem was related with HibernateTools, not with Seam.
Here is the DDL of the table against which I made my test:
CREATE TABLE PEOPLE ("ID" NUMBER NOT NULL, "SURNAME" VARCHAR2(50 BYTE), "NAME" VARCHAR2(25 BYTE), CONSTRAINT "PEOPLE_PK" PRIMARY KEY ("ID"));
Regards,
Ali Sadik Kumlali
--
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
12 years, 3 months
[Hibernate-JIRA] Created: (ANN-630) @ManyToMany and @Index
by Peter K. Guldbæk (JIRA)
@ManyToMany and @Index
----------------------
Key: ANN-630
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-630
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga
Environment: Windows Vista
java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)
Reporter: Peter K. Guldbæk
I have trouble adding an index to a column of a table which is part of a many-to-many property mapping. The following example causes a NullPointerException when generating the DDL (the exception can be seen at the end of my post):
@Entity @Table(name="usr")
public class User implements Serializable
{
@Id @GeneratedValue(strategy=GenerationType.AUTO)
public Integer id;
@ManyToMany(targetEntity=Target.class, cascade={})
@Index(name="fkey_usr_target", columnNames="usr_id")
@JoinTable(name="usr_target",
joinColumns=@JoinColumn(name="usr_id"),
inverseJoinColumns=@JoinColumn(name="target_id"))
public Collection<Target> targets;
}
@Entity @Table(name="target")
public class Target implements Serializable
{
@Id @GeneratedValue(strategy=GenerationType.AUTO)
public Integer id;
@Basic
public String myValue;
}
NullPointerException thrown when an @Index annotation is used with a @ManyToMany:
java.lang.NullPointerException
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1594)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:733)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:498)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:56)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:299)
at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:183)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.Main.runBuild(Main.java:698)
at org.apache.tools.ant.Main.startAnt(Main.java:199)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
--
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
12 years, 4 months
[Hibernate-JIRA] Created: (HHH-2318) Sometimes wrong classloader used for proxy interfaces
by Jan Wiemer (JIRA)
Sometimes wrong classloader used for proxy interfaces
-----------------------------------------------------
Key: HHH-2318
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2318
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.1
Reporter: Jan Wiemer
For some of our business classes we used a Mapping declaring the class to be lazy initialized and providing a proxy interface like e.g.:
<class name="TestClassImpl" proxy="TestClass" table="testTable" lazy="true"> ... </class>
Using classes mapped this way - e.g. as endpoint of a one to one relation - sporadically leads to exceptions like the following:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of test.AbstractTestClass2Impl.testField
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200)
at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3514)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2211)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
at org.hibernate.loader.Loader.list(Loader.java:2090)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:388)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:804)
Note that the application is residing in a different classloader than hibernate (and CGLIB...).
Examining the situation we see that the value passed to the setter was a CGLIB proxy. Internally the proxy stores an array of interfaces the proxy should implement. In our situation this interface contains the HibernateProxy interface and our business interface provided as proxy interface in the mapping. In this interface array we checked the classloader of the interfaces. As expected the HibernateProxy interface is loaded by the system classloader and our interface was loaded by our custom classloader. However examining the actual interfaces of the proxy (with proxy.getClass().getInterfaces()[i].getClassLoader() for all i) shows that all interfaces are loaded with the system classloader. This causes the exception above.
Doing some more experiments we experience that the problem does not occur all the time. Sometimes the actual proxy interfaces are as expected (the HibernateProxy interface is loaded by the system classloader and our interface was loaded by our custom classloader). We notice that each time the test failed the HibernateProxy was the first interface in the interface array stored in the proxy.
Some experiments with the CGLIB (the Enhancer class) shows us that (if there is no superclass given) they use the classloader of the first passed interface as default classloader (compare method net.sf.cglib.proxy.Enhancer.getDefaultClassLoader()).
Finally we find out that hibernate passes the proxy interfaces in an arbitrary order since they are using a HashSet for the proxy interfaces in the method org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PersistentClass persistentClass, Getter idGetter, Setter idSetter). This Hash set is passed to the method org.hibernate.proxy.pojo.cglib.CGLIB_ProxyFactory.postInstantiate(...). There it is simply converted to an Array (leading to a randomized order).
As a workaround it is possible to patch the class org.hibernate.proxy.pojo.cglib.CGLIB_ProxyFactory and add reorganize the array if the HibernateProxy interface is the first one:
this.interfaces = (Class[]) interfaces.toArray(NO_CLASSES);
//----->PATCH<--------
if(this.interfaces.length > 1) {
Class firstIfc = this.interfaces[0];
if(firstIfc.getName().startsWith("org.hibernate")) {
this.interfaces[0] = this.interfaces[1];
this.interfaces[1] = firstIfc;
System.err.println("Replace: " + firstIfc.getName() + " by " + this.interfaces[0].getName());
}
}
//--------------------
After applying this patch everything woks as expected.
Compare with the discussion in:
http://forum.hibernate.org/viewtopic.php?p=2334617#2334617
--
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
12 years, 4 months
[Hibernate-JIRA] Created: (HHH-2808) CLONE -Impossible to define caching for a subclass's collection in hibernate.cgf.xml
by Sebastien Blind (JIRA)
CLONE -Impossible to define caching for a subclass's collection in hibernate.cgf.xml
-------------------------------------------------------------------------------------
Key: HHH-2808
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2808
Project: Hibernate3
Issue Type: Bug
Components: caching (L2)
Affects Versions: 3.2.5
Environment: Hibernate 3.2.5
Sybase
Reporter: Sebastien Blind
Basically, hibernate allows to define <cache usage="transactional"/> inside the subclass mapping, i.e.
<subclass name="SubClass" extends="BaseClass" discriminator-value="xxx">
<bag name="subClassLinks" lazy="false" inverse="true" batch-size="100">
<cache usage="transactional" region="xxx"/>
<key column="xxx" not-null="true"/>
<one-to-many class="xxx"/>
</bag>
<join table="xxx">
</join>
</subclass>
but it's not allowed to do the same using <collection-cache collection="subClass.myCollection" region="xxx" usage="transactional"/>.
It throws:
Exception in thread "main" org.hibernate.MappingException: Cannot cache an unknown collection: subClass.myCollection
at org.hibernate.cfg.Configuration.setCollectionCacheConcurrencyStrategy(Configuration.java:1984)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1568)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
--
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
12 years, 4 months
[Hibernate-JIRA] Created: (HHH-2851) ParameterTranslationsImpl fails to correctly determine parameter type
by Alex Savitsky (JIRA)
ParameterTranslationsImpl fails to correctly determine parameter type
---------------------------------------------------------------------
Key: HHH-2851
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2851
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.5
Reporter: Alex Savitsky
Priority: Minor
For the conditions in the form "(:param IS NULL OR alias.someField = :param)", the HQL parses would not correctly determine the type of param, unless the conditions are swapped like "(alias.someField = :param OR :param IS NULL)". The reason is that NamedParamTempHolder classes are created for all parameter entries, in the order they appear in the query. The first occurrence (:param IS NULL) would have its expectedType set to null, and the second occurrence would use the param holder created by the first occurrence, without checking whether it can improve it in any way (which it can - the expectedType for second occurrence is correctly determined to be Long).
Proposed fix would be to check for this particular condition, enhancing paramHolder if possible, with new information:
old code:
if ( paramHolder == null ) {
paramHolder = new NamedParamTempHolder();
paramHolder.name = namedSpec.getName();
paramHolder.type = namedSpec.getExpectedType();
namedParameterMap.put( namedSpec.getName(), paramHolder );
}
new code:
if ( paramHolder == null ) {
paramHolder = new NamedParamTempHolder();
paramHolder.name = namedSpec.getName();
paramHolder.type = namedSpec.getExpectedType();
namedParameterMap.put( namedSpec.getName(), paramHolder );
+ } else if (paramHolder.getExpectedType() == null && namedSpec.getExpectedType() != null) {
+ paramHolder.type = namedSpec.getExpectedType();
}
--
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
12 years, 5 months