[Hibernate-JIRA] Created: (EJB-337) Entity scaning failing when path protocol is "file:" (not jar) and it contains spaces
by valery gorbunov (JIRA)
Entity scaning failing when path protocol is "file:" (not jar) and it contains spaces
-------------------------------------------------------------------------------------
Key: EJB-337
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-337
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.3.1.GA
Environment: OS Linux
Hibernate 3.2.5ga
HiberanteEM -3.3.1ga
Reporter: valery gorbunov
Priority: Critical
Entity scanning failed when path contains spaces
Stack trace is:
java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file
at org.jboss.util.file.JarArchiveBrowser.<init>(JarArchiveBrowser.java:74)
at org.jboss.util.file.FileProtocolArchiveBrowserFactory.create(FileProtocolArchiveBrowserFactory.java:48)
at org.jboss.util.file.FileProtocolArchiveBrowserFactoryTest.testCreate(FileProtocolArchiveBrowserFactoryTest.java:29)
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:597)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
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)
Caused by: java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:114)
at java.util.jar.JarFile.<init>(JarFile.java:133)
at java.util.jar.JarFile.<init>(JarFile.java:97)
at org.jboss.util.file.JarArchiveBrowser.<init>(JarArchiveBrowser.java:69)
... 24 more
Problem in FileProtocolArchiveBrowserFactory class
see test:
package org.jboss.util.file;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import junit.framework.Assert;
import org.junit.Test;
/**
*
* @author Valery Gorbunov <a href=mailto:vgorbunov@comodo.com.ua>vgorbunov(a)comodo.com.ua</a>
*/
public class FileProtocolArchiveBrowserFactoryTest {
@Test
public void testCreate() throws MalformedURLException, URISyntaxException {
URI uri = new URI("file:/tmp/Path%20with%20space");
File f = new File(uri);
if (!f.exists()) {
Assert.assertTrue(f.mkdir());
}
FileProtocolArchiveBrowserFactory factory = new FileProtocolArchiveBrowserFactory();
Object ab = factory.create(f.toURI().toURL(), null);
assertNotNull(ab);
assertTrue(ab instanceof DirectoryArchiveBrowser);
}
}
--
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
15 years, 9 months
[Hibernate-JIRA] Created: (HHH-2782) Component getType caches the type value
by Kiss Zoltán (JIRA)
Component getType caches the type value
---------------------------------------
Key: HHH-2782
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2782
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.5
Environment: all
Reporter: Kiss Zoltán
Component class caches the value of the type attribute:
public Type getType() throws MappingException {
// added this caching as I noticed that getType() is being called multiple times...
if ( type == null ) {
type = buildType();
}
return type;
}
This forbids the use of 'dynamic attributes'.
For eg. if you try to add new properties to an existing dynamic-component with the addProperty method, then the rebuild of the session factory will failed, because the Component property will be invalid during the validation (in the Component there will be a different column span value, then in the cached ComponentType).
There should be a method like this in the Component class:
public void rebuildType() {
type = buildType();
}
With the help of this the type could be rebuild if it is necessary.
--
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
15 years, 9 months
[Hibernate-JIRA] Created: (HHH-3128) NullPointerException while building SessionFactory when using native sql query for loading many-to-many mapped collections
by Juergen Denzel (JIRA)
NullPointerException while building SessionFactory when using native sql query for loading many-to-many mapped collections
--------------------------------------------------------------------------------------------------------------------------
Key: HHH-3128
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3128
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.6, 3.2.5
Environment: Hibernate 3.2.6
Reporter: Juergen Denzel
Attachments: src.zip
Hi,
I am trying to load a many-to-many mapped collection using a sql query like this:
<sql-query name="loadItems">
<load-collection alias="item" role="test.Test.items"/>
select {item.*} from Items item where item.id = :id
</sql-query>
This always fails due to a NullPointerException:
java.lang.NullPointerException
at org.hibernate.loader.custom.sql.SQLQueryParser.resolveProperties(SQLQueryParser.java:182)
at org.hibernate.loader.custom.sql.SQLQueryParser.resolveCollectionProperties(SQLQueryParser.java:135)
at org.hibernate.loader.custom.sql.SQLQueryParser.substituteBrackets(SQLQueryParser.java:98)
at org.hibernate.loader.custom.sql.SQLQueryParser.process(SQLQueryParser.java:51)
at org.hibernate.loader.custom.sql.SQLCustomQuery.<init>(SQLCustomQuery.java:110)
at org.hibernate.engine.query.NativeSQLQueryPlan.<init>(NativeSQLQueryPlan.java:43)
at org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:114)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:446)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:352)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
at test.HibernateTest.testSessionFactory(HibernateTest.java:18)
I provided a very simple TestCase + Mappings to illustrate the problem. The exception does not occur for one-to-many mappings.
Just for your information, we need this functionality in order to deal with DB2 problems we have.
I ran this TestCase against 3.2.5 and 3.2.6 and both failed.
Thanks.
Juergen Denzel
--
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
15 years, 9 months
[Hibernate-JIRA] Created: (HHH-3148) Exception thrown by debug trace code: ComponentType toLoggableString
by Pete Geraghty (JIRA)
Exception thrown by debug trace code: ComponentType toLoggableString
--------------------------------------------------------------------
Key: HHH-3148
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3148
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.6
Environment: Hibernate 3.2.6.ga
HibernateAnnotations 3.3.0.ga
Oracle 10g Express Edition
Reporter: Pete Geraghty
Priority: Minor
Attachments: ToLoggableStringExample.txt
The method toLoggableString in ComponentType is used to provide tracing output when running with log level DEBUG. In some circumstances it throws a ClassCastException.
This is not a good idea in tracing code and obscures underlying problems.
In my case the underlying problem was a previous incorrect call to set a parameter value in a query. I saw that previous JIRA issues have mentioned this ClassCastException as a side effect of other underlying problems - it is a distraction and time-waster.
Lines 375-378 read:
EntityMode entityMode = tuplizerMapping.guessEntityMode( value );
if ( entityMode == null ) {
throw new ClassCastException( value.getClass().getName() );
}
A better solution would be to just us String.valueOf
EntityMode entityMode = tuplizerMapping.guessEntityMode( value );
if ( entityMode == null ) {
return String.valueOf(value);
}
Another possibility would be to concatenate some diagnostic message with String.valueOf, but personally I don't think that be helpful.
Stack trace is:
Exception in thread "main" java.lang.ClassCastException: java.lang.String
at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:377)
at org.hibernate.pretty.Printer.toString(Printer.java:76)
at org.hibernate.engine.QueryParameters.traceParameters(QueryParameters.java:277)
at org.hibernate.engine.query.HQLQueryPlan.performIterate(HQLQueryPlan.java:210)
at org.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1192)
at org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:46)
at hib.example.EntityWithEmbeddable.main(EntityWithEmbeddable.java:44)
Example code for the classes and schema to reproduce is pasted into the attachment.
--
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
15 years, 9 months
[Hibernate-JIRA] Created: (HHH-3785) HQL parser not throwing error for unmatched parantheses
by Amaresh wakkar (JIRA)
HQL parser not throwing error for unmatched parantheses
-------------------------------------------------------
Key: HHH-3785
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3785
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.6
Environment: Hibernate 3.2.6, Sybase ASE 12, Windows XP SP2
Reporter: Amaresh wakkar
I have following query which I would have expected HQL parser to throw QuerySyntaxException:unexpected token.
================================
from WebAuditLog wal where wal.tmstampLastModified >= convert(date, '18-FEB-09', 111)
and wal.tmstampLastModified <= convert(date, '18-FEB-09', 111))
and wal.sourceId = 'I'
order by wal.client.clientId, wal.tmstampLastModified
====================================
The problem with this query is that on Line#2, there is a redundant unmatched right parantheses i.e. ')' . Ideally this should have been reported as Query syntax exception by HQL parser. Unfortunately, what HQL parses does is
1. ignores everything beyond that errorneous right parantheses
2. Executes such terminated query and returns results which gives impression to user that query is syntactically valid and errors must be either with data or logic of query.
Workaround:
In absensce of HQL parses throwing error, we must ensure that the HQL is correctly written by reviewing it carefully.
Steps to replicate:
1.Create any table which has 2 or 3 columns
2. Try writing a HQL which uses parantheses e.g. functions like convert etc. Add an extra right parantheses at the end of such function's closing right parantheses
3. add additional where clause filtering criteria after step-2
4. Execute the query.
5. In the result you would notice that the where clause criteria mentioned in step-3 is ignored and query is executed as if the query terminated at step-2
I have done a quick search through existing bugs but couldn't find any matching right away so reporting it here.
Hope it helps to make Hibernate HQL parser even more robust
Thanks and regards,
Amaresh Wakkar
--
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
15 years, 9 months