[Hibernate-JIRA] Created: (HHH-2306) put() fails on lazy one-to-many Map
by Andreas Idl (JIRA)
put() fails on lazy one-to-many Map
-----------------------------------
Key: HHH-2306
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2306
Project: Hibernate3
Type: Bug
Versions: 3.2.0.ga, 3.2.1
Environment: HIbernate 3.2.1. with Mysql 4
Reporter: Andreas Idl
Priority: Critical
Attachments: MapTest.zip
If I add n objects to a lazy-loaded one-to-many map, the first added object is not contained afterwards.
The size of the map is (n-1).
Document document = (Document) session.load(Document.class,documentId);
DocumentHistory history = new DocumentHistory();
history.setVersion(1);
history.setTitle(document.getTitle());
history.setContent(document.getContent());
history.setDocument(document);
// Put the new history into the map.
Map<Integer, DocumentHistory> histories = document.getHistories();
histories.put(history.getVersion(), history);
//not equal because histories.size() is 0
assertEquals(1, histories.size());
--
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, 2 months
[Hibernate-JIRA] Created: (HBX-819) NullPointerException in simple case with one configuration file and two console configurations
by Francois Granade (JIRA)
NullPointerException in simple case with one configuration file and two console configurations
----------------------------------------------------------------------------------------------
Key: HBX-819
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-819
Project: Hibernate Tools
Type: Bug
Components: consoleconfiguration
Versions: 3.2beta8
Environment: macos, hsqldb
Reporter: Francois Granade
Priority: Minor
I'm having an NullPointerException (See the stack below), I'm not really able to understand what triggers it (it is not completely reproducible, it seems).
My setup is very simple: just one Java project, one hibernate configuration file, two console configurations, nothing else. The only thing that's a little special, is that one of the console configuration is invalid (no driver jar file defined).
I'll try to describe it as precisely as possible:
- I have a very simple HSQLDB server, just out-of-the box. I have created only one table with: "create table x (a varchar(255), b int)".
- I created an Hibernate configuration file for the HSQLDB database using "File > New > Others", "Hibernate > Hibernate configuration file"; I specified "create a console configuration", and I gave a name to the Console Configuration, but I didn't set any other property (in particular, I did not specify the .jar file for hsqldb: so it's not a correctly defined console configuration)
- Then I created a second console configuration; That time, in the 'classpath' section at the bottom, I selected 'add external jar' and added my 'hsqldb.jar'.
- I can now open the HSQL DB correctly in the Hibernate Configuration view, with this second console configuration (the first one is doing an error, which is normal).
- now, time to time, when I right-click on the definition of my table ('X"), and select "HQL Editor", I sometimes get the NullPointerException (but not always).
here's the stack trace:
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench".
!STACK 0
java.lang.NullPointerException
at java.util.TreeMap.compare(TreeMap.java:1093)
at java.util.TreeMap.getEntry(TreeMap.java:347)
at java.util.TreeMap.get(TreeMap.java:265)
at org.hibernate.console.KnownConfigurations.find(KnownConfigurations.java:225)
at org.hibernate.eclipse.console.AbstractQueryEditor.getConsoleConfiguration(AbstractQueryEditor.java:51)
at org.hibernate.eclipse.console.views.DynamicSQLPreviewView.updateText(DynamicSQLPreviewView.java:137)
at org.hibernate.eclipse.console.views.DynamicSQLPreviewView.setCurrentEditor(DynamicSQLPreviewView.java:130)
at org.hibernate.eclipse.console.views.DynamicSQLPreviewView.hookIntoEditor(DynamicSQLPreviewView.java:114)
at org.hibernate.eclipse.console.views.DynamicSQLPreviewView.access$2(DynamicSQLPreviewView.java:107)
at org.hibernate.eclipse.console.views.DynamicSQLPreviewView$1.partBroughtToTop(DynamicSQLPreviewView.java:92)
at org.eclipse.ui.internal.PartListenerList2$2.run(PartListenerList2.java:83)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:843)
at org.eclipse.ui.internal.PartListenerList2.fireEvent(PartListenerList2.java:53)
at org.eclipse.ui.internal.PartListenerList2.firePartBroughtToTop(PartListenerList2.java:81)
at org.eclipse.ui.internal.PartService.firePartBroughtToTop(PartService.java:90)
at org.eclipse.ui.internal.WWinPartService$1.partBroughtToTop(WWinPartService.java:40)
at org.eclipse.ui.internal.PartListenerList2$2.run(PartListenerList2.java:
--
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, 3 months
[Hibernate-JIRA] Created: (HHH-2034) Potential ClassCastException in catch block in NullableType
by Galen Palmer (JIRA)
Potential ClassCastException in catch block in NullableType
-----------------------------------------------------------
Key: HHH-2034
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2034
Project: Hibernate3
Type: Improvement
Components: core
Versions: 3.1.3
Environment: Hibernate 3.1.3
Reporter: Galen Palmer
Priority: Minor
It is possible to throw an exception from within the catch block of NullableType.nullSafeSet() since the toString(value) method calls in many cases (e.g. StringType) simply result in a cast of return (String)value. This may mask the underlying problem for the users.
A proposed solution would be to replace the call in the catch blog of toString(value) with a reference to value. For example:
line 87:
log().info( "could not bind value '" + value + "' to parameter: " + index + "; " + re.getMessage() );
and line 91:
log().info( "could not bind value '" + value + "' to parameter: " + index + "; " + se.getMessage() );
This change would prevent the catch block from throwing the exception.
--
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, 3 months
[Hibernate-JIRA] Created: (EJB-242) Eclipse RCP + InputStreamZippedJarVisitor problem
by Michał Kostrzewa (JIRA)
Eclipse RCP + InputStreamZippedJarVisitor problem
-------------------------------------------------
Key: EJB-242
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-242
Project: Hibernate Entity Manager
Type: Bug
Components: EntityManager
Versions: 3.2.0.ga
Environment: Hibernate 3.2.0 GA, postgres (but I guess not relevant here)
Reporter: Michał Kostrzewa
Hi,
Max from user list kindly redirected me to fill a bug here. Here it goes as I described it on list. I didn't attached a test case b/c doing it is non-trivial, maybe you'll just know what is the problem and I provided a patch that works for me. But if test case is needed - I'll do it.
--------------
I'm having problems with bundling hibernate and my ejb model in eclipse RCP application. I managed to solve all classloading problems but one, related to InputStreamZippedJarVisitor class.
Simplifying things I have:
hibernate plugin which registers itself for buddy classloading policy
dbmodel plugin which depends on hibernate and is a buddy of hibernate
application plugin which depends on hibernate and dbmodel and is a buddy of hibernate. This application plugin has hibernate.cfg.xml in self.
When I run this project from eclipse IDE, all is fine except the warning message in logs while creating EntityManager:
2006-10-20 09:07:23 org.hibernate.ejb.packaging.InputStreamZippedJarVisitor doProcessElements
WARNING: Unable to find file (ignored): bundleresource://101
java.io.FileNotFoundException: C:\Documents and Settings\mkostrze\sv-head2\com.pentacomp.dbmodel (Access denied)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at org.eclipse.osgi.framework.util.SecureAction.getFileInputStream(SecureAction.java:99)
at org.eclipse.osgi.baseadaptor.bundlefile.FileBundleEntry.getInputStream(FileBundleEntry.java:50)
at org.eclipse.osgi.framework.internal.core.BundleURLConnection.connect(BundleURLConnection.java:53)
at org.eclipse.osgi.framework.internal.core.BundleURLConnection.getInputStream(BundleURLConnection.java:99)
at java.net.URL.openStream(URL.java:1007)
at org.hibernate.ejb.packaging.InputStreamZippedJarVisitor.doProcessElements(InputStreamZippedJarVisitor.java:33)
at org.hibernate.ejb.packaging.JarVisitor.getMatchingEntries(JarVisitor.java:215)
at org.hibernate.ejb.Ejb3Configuration.addMetadataFromVisitor(Ejb3Configuration.java:253)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:229)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at com.pentacomp.dicom.viewer.ViewerContstants.createEntityManager(ViewerContstants.java:170)
at com.pentacomp.dicom.viewer.DicomViewerMainFrame$InitRepositoriesTask.call(DicomViewerMainFrame.java:146)
I suppose hibernate tries to inspect the model jar for some reason, but in IDE this jar location is resolved to directory containing the plugin.
But things get worse when I export the project into java webstart application. I'm getting NullPointerException instead of warning in the same place. I investigated the source and the problem is here:
protected void doProcessElements() throws IOException {
JarInputStream jis;
try {
jis = new JarInputStream( jarUrl.openStream() );
}
catch (IOException ze) {
log.warn( "Unable to find file (ignored): " + jarUrl, ze );
return;
}
The jarUrl is a bundleresource:// url which resolves to DirZipBundleEntry which in turn returns null in getInputStream(). Thus JarInputStream thows NPE.
Here's what I've tried to solve this:
- configure the dbmodel to be unpacked or packed after install
- tried dbmodel with jar inside or with unpacked classes inside
- set hibernate.archive.autodetection to 'none'. (I did it passing parameters map to createEntityManager method)
- change the hibernate sources and replace IOException with Exception in doProcessElement method. This one worked
I guess most likely I did something wrong to my deploy - any ideas please? But if not, perhaps such a change in code may make hibernate more robust (?)
Hibernate version: 3.2.0 GA
best regards,
Michal Kostrzewa
--
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: (EJB-250) Ejb3Configuration class issue
by David Avenante (JIRA)
Ejb3Configuration class issue
-----------------------------
Key: EJB-250
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-250
Project: Hibernate Entity Manager
Type: Bug
Versions: 3.2.0.ga
Environment: Hibernate version : 3.2.0.ga.
Db : H2
Reporter: David Avenante
Priority: Minor
Hi,
I try for my test to use my entityManager out of container.
For that i instanciate my entityManagerFactory through the Ejb3Configuration helper.
All it's ok (annoted classes found, connection ok ...) but not my transactionType !!!!
i try to add the property "javax.persistence.transactionType" ->"RESOURCE_LOCAL" without success
After inspection of sources it's seem this property is available through the configure() method who need the name of a file configuration.
But i don't want that a want define my entityManager only programaticly.
Ok so after some investigations.
Ejb3Configuration cfg = new Ejb3Configuration();
cfg.addProperties(getProperties());
cfg.addAnnotatedClass(User.class);
entityManagerFactory = cfg.buildEntityManagerFactory();
private static Properties getProperties() {
Properties properties = new Properties();
properties.setProperty(Environment.DRIVER, DATABASE_DRIVER_CLASS);
properties.setProperty(Environment.URL, MEMORY_DATABASE_URL);
properties.setProperty(Environment.USER, USERNAME);
properties.setProperty(Environment.PASS, PASSWORD);
properties.setProperty(Environment.DIALECT, DBDIALECT);
properties.put(Environment.SHOW_SQL, "true");
properties.put(Environment.FLUSH_BEFORE_COMPLETION, "false");
properties.put(Environment.TRANSACTION_STRATEGY, PersistenceUnitTransactionType.RESOURCE_LOCAL);
properties.put(Environment.HBM2DDL_AUTO, "create");
return properties;
}
This code don't work because my entityManagerFactory doesn't have TransactionStrategy attached.
But if i use this code
Ejb3Configuration cfg = new Ejb3Configuration();
cfg.addProperties(getProperties());
cfg.addAnnotatedClass(User.class);
cfg.configure("hibernate.cfg.xml");
entityManagerFactory = cfg.buildEntityManagerFactory();
with a empty hibernate.cfg.xml config file like that ...
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
</session-factory>
</hibernate-configuration>
the entityManagerFactory have a transaction manager attached !!!!
You can reply me hey guys all is ok good but not really. Because we can see the cfg.configure("hibernate.cfg.xml") don't use a resource or an input stream but a string. So the location of my file must be in my source directory but i dont want that. I want to use my file in my test directory tree.
So emmanuel ask me to open and issue ;)
--
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