[Hibernate-JIRA] Created: (HHH-2363) Hibernate is returning zero for the ID of a persistent object
by Archie Cobbs (JIRA)
Hibernate is returning zero for the ID of a persistent object
-------------------------------------------------------------
Key: HHH-2363
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2363
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.ga
Environment: Hibernate 3.2.1 GA running on SuSE Linux
MySQL 4.1.13
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
Reporter: Archie Cobbs
I have two classes, {{Patient}} and {{Room}}, where {{Patient}} has a FK many-to-one reference to {{Room}}, representing a room assignment.
Both classes use a Java {{long}} field named "id" as their identifier.
When I create a Session and find a Patient with a room assignment, the Patient's identifier is correct but the Room's identifier, when accessed via {{patient.getAssignedRoom().getId()}}, is ZERO. However, in the database the value is one and {{session.getIdentifier(patient.getAssignedRoom())}} also returns one, in contradiction.
A simple reproducible test case will be attached. Instructions:
# Edit {{doit.sh}} and set {{HIBERNATE_DIR}} to point to an unpacked {{hibernate-3.2.0.ga.tar.gz}} directory
# Set {{MYSQL_CONNECTOR_JAVA}} to point to {{myslq-connector-java.jar}}
# Set {{DATABASE_USERNAME}} and {{DATABASE_PASSWORD}} if needed
# Run {{doit.sh}}.
The output I get at the end is this:
{noformat}
2037 [main] INFO org.hibernate.cache.StandardQueryCache - starting query cache at region: org.hibernate.cache.StandardQueryCache
Hibernate: select this_.id as id0_0_, this_.assignedRoom as assigned2_0_0_, this_.name as name0_0_, this_.medicalRecordNumber as medicalR4_0_0_ from Patient this_ where this_.medicalRecordNumber=?
Hibernate: select room0_.id as id1_0_, room0_.name as name1_0_ from Room room0_ where room0_.id=?
2195 [main] INFO Main - patient=Patient[Fred Example] patient.assignedRoom=Room[Room 101]
2196 [main] INFO Main - patient.id=1
2196 [main] INFO Main - patient.assignedRoom.id=0
2196 [main] ERROR Main - WTF? ID OF ROOM IS ZERO!
2196 [main] INFO Main - patient.assignedRoom.id=1
{noformat}
Note the line {{patient.assignedRoom.id=0}} ... see the corresponding code in {{Main.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, 8 months
[Hibernate-JIRA] Created: (HHH-2187) bad query results exposes IllegalArgumentException instead of an HibernateException
by Max Rydahl Andersen (JIRA)
bad query results exposes IllegalArgumentException instead of an HibernateException
-----------------------------------------------------------------------------------
Key: HHH-2187
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2187
Project: Hibernate3
Type: Bug
Components: query-hql
Reporter: Max Rydahl Andersen
s.createQuery("kkk");
results in an IllegalArgumentException being thrown making the exception bubble
through the expected catch HibernateException clauses in e.g. the tools.
Cause is:
public void traverseDepthFirst(AST ast) {
if ( ast == null ) {
throw new IllegalArgumentException( "node to traverse cannot be null!" );
}
visitDepthFirst( ast.getFirstChild() );
}
in NodeTraverser.
java.lang.IllegalArgumentException: node to traverse cannot be null!
at org.hibernate.hql.ast.util.NodeTraverser.traverseDepthFirst(NodeTraverser.java:31)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:254)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at org.hibernate.console.HQLQueryPage.setSession(HQLQueryPage.java:103)
at org.hibernate.console.ConsoleConfiguration$3.execute(ConsoleConfiguration.java:309)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:56)
at org.hibernate.console.ConsoleConfiguration.executeHQLQuery(ConsoleConfiguration.java:304)
at org.hibernate.eclipse.hqleditor.HQLEditor.executeQuery(HQLEditor.java:374)
at org.hibernate.eclipse.console.actions.ExecuteQueryAction.execute(ExecuteQueryAction.java:72)
at org.hibernate.eclipse.console.actions.ExecuteQueryAction.run(ExecuteQueryAction.java:52)
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-2343) SchemaUpdate and c3p0 connection pool too many connections
by Vlad Skarzhevskyy (JIRA)
SchemaUpdate and c3p0 connection pool too many connections
----------------------------------------------------------
Key: HHH-2343
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2343
Project: Hibernate3
Type: Bug
Components: build
Versions: 3.2.1
Environment: hibernate 3.2.1.ga, hibernate-annotations, oracle ojdbc14_g 10.2.0.2, c3p0 0.9.0 or 0.9.0.4, Sun Java 1.5.0.10, Win XP.
Reporter: Vlad Skarzhevskyy
- I have application, configured to use c3p0 as connection pool
<property name="c3p0.max_size">2</property>
- When SchemaUpdate is enabled
<property name="hibernate.hbm2ddl.auto">update</property>
Application (hibernate) creates ~100 connections to database and c3p0 pool initialized 42 times. (looks like number of entities in my domain)
There are no problems like this in hibernate 3.2.0.ga
I see this log statement 42 times in log
INFO Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@15a4a77
[ ... initialPoolSize -> 2, ... maxPoolSize -> 2, ]
INFO 2007-01-04 13:39:55,796 2031- [..] [C3P0Registry.banner:77] com.mchange.v2.c3p0.C3P0Registry.banner(C3P0Registry.java:77) [main]
Initializing c3p0-0.9.0.4 [built 23-January-2006 22:20:29 -0500; debug? true; trace: 10]
INFO 2007-01-04 13:39:56,093 2328- [..] [PoolBackedDataSource.getPoolManager:257] com.mchange.v2.c3p0.PoolBackedDataSource.getPoolManager(PoolBackedDataSource.java:257) [main]
Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@bc312f [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@5f1ba8 [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 5f1ba8, idleConnectionTestPeriod -> 3000, initialPoolSize -> 2, maxIdleTime -> 5000, maxPoolSize -> 2, maxStatements -> 100, maxStatementsPerConnection -> 0, minPoolSize -> 2, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@13c4c09 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 13c4c09, jdbcUrl -> jdbc:oracle:thin:@torvspocapp:1522:ENT10, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -> bc312f, numHelperThreads -> 3 ]
......
And so on 42 times.
hibernate.cfg.xml
----
<property name="hibernate.connection.pool_size">0</property>
<property name="c3p0.acquire_increment">1</property>
<property name="c3p0.min_size">2</property>
<property name="c3p0.max_size">2</property>
<property name="c3p0.timeout">5000</property>
<property name="c3p0.idle_test_period">3000</property>
<property name="c3p0.max_statements">100</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
----
--
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, 9 months
[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, 9 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, 9 months