[Hibernate-JIRA] Created: (ANN-599) @MapKey throws an exception if the key is part of a non-embedded composite ID
by Chris Rose (JIRA)
@MapKey throws an exception if the key is part of a non-embedded composite ID
-----------------------------------------------------------------------------
Key: ANN-599
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-599
Project: Hibernate Annotations
Issue Type: Bug
Components: binder
Affects Versions: 3.3.0.ga
Environment: Hibernate Core 3.2.3, Annotations 3.3.0.GA, Oracle 9i, Java5
Reporter: Chris Rose
Priority: Minor
Like mentioned in ANN-43, the property binder for MapKey does not completely handle identifier properties in the owned entity. Unlike that issue, which is clearly fixed, this issue comes when the mapped entity has a composite primary key that is _not_ handled with a separate PK class.
For example:
class Owner {
@Id
Long getOwnerId () {}
@OneToMany(mappedBy="owner")
@MapKey(name="propertyName")
Map<String,Value> getProperties (){}
}
class Value {
@Id
String getPropertyName () {}
@Id
Long getOwnerId (){}
@ManyToOne
@JoinColumn(name="owner_id")
Owner getOwner ()
}
This generates an exception when I initialize the session:
11:36:27,800 INFO CollectionBinder:627 - Mapping collection: Owner.properties -> properties
Exception in thread "main" org.hibernate.AnnotationException: Map key property not found: Value.propertyName
at org.hibernate.cfg.annotations.MapBinder.bindKeyFromAssociationTable(MapBinder.java:103)
at org.hibernate.cfg.annotations.MapBinder.access$000(MapBinder.java:53)
at org.hibernate.cfg.annotations.MapBinder$1.secondPass(MapBinder.java:83)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:316)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at com.planet.core.SessionFactoryTest.main(SessionFactoryTest.java:46)
>From the code, it's clear that the BinderHelper.findPropertyByName () method only acquires the _first_ identifier property on the Value class, which appears to be the alphabetically first one, rather than the multiple ones.
--
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-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] Commented: (HHH-1936) IdentityGenerator doesn't support BigInteger as a valid identity type.
by Andrew Thompson (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1936?page=c... ]
Andrew Thompson commented on HHH-1936:
--------------------------------------
To break the original issue down a bit for clarity:
* Sybase *requires* that all auto-increment identity columns be of type numeric:
e.g. create table Foo ( foo_id numeric(9,0) identity )
* Sybase's JConnect drvier maps this to BigInteger (well BigDecimal really) in Java code [*] see below
* Hibernate won't allow BigInteger as a primary key column for an object, due, I think, to code in IdentityGeneratorFactory which checks explicitly
Result - we're caught between the proverbial rock and hard place.
So to partially get around this, we do this:
<id name="fooNum" column="foo_id" type="com.example.hibernate.usertype.NumericType">
<generator class="identity" />
</id>
And NumericType is then a bit ghastly....
public class NumericType extends LongType {
public void set(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
st.setBigDecimal( index, new BigDecimal( BigInteger.valueOf(((Long)value).longValue())));
}
public int sqlType() {
return Types.NUMERIC;
}
}
Basically the field in our class is then a Long and we fake out the mapping from Long to Numeric here.
There's a side issue where every time we want to use HQL or criteria queries, we have to be very careful to always remember to call Query.setBigDecimal() and convert the Long to an BigInteger manually. If we don't do that (i.e. we call setLong or let Hibernate figure it out) then the Sybase JConnect driver emits SQL code which causes the database to ignore the index (because the types don't match) and we table scan the table.
What we want to do is to change our class to use BigInteger as the id column, because that's really what is needed with Sybase, but the checks in Hibernate won't allow that.
> IdentityGenerator doesn't support BigInteger as a valid identity type.
> ----------------------------------------------------------------------
>
> Key: HHH-1936
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1936
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5
> Environment: Hibernate 3.0.5, Sybase 12.05, Window/ Unix
> Reporter: Leonid Shtivelman
>
> Identity generator strategy doesn't support BigInteger as a valid id type. This causes problem with Sybase which requires identity column to be numeric. It would seem an obvious way to get around this problem is to set column mapping to long in hibernate xml and the actual java object. This will solve obvious problem of creating identity, but will cause performance problem on selection. In order for Sybase to use index for parameter query the variable type of the parameter and column index type has to be the same. If ones maps column type to Long, Hibernate will use JDBC method setLong(long) to set value in the prepared statement. This will cause mismatch between parameter type and column index type, and Sybase will not use index to locate index. As you can see this is a big problem for anyone that is using identity columns Sybase and Hibernate
--
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-932) reveng creates field names which are Java reserved words
by Gary Plante (JIRA)
reveng creates field names which are Java reserved words
--------------------------------------------------------
Key: HBX-932
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-932
Project: Hibernate Tools
Issue Type: Bug
Components: reverse-engineer
Affects Versions: 3.2beta9
Environment: Hibernate 3.2; MS-SQL 2000; Eclipse 3.2.1
Reporter: Gary Plante
Priority: Minor
I am using the reverse engineering tool to create POJO's from an existing database (schema).
Unfortunately, one of the tables names happens to be the same as a Java reserved word (i.e. Switch). The tool creates the .java code and uses the lower case 'switch' as the name of field (if the the table is referenced by another table). This causes the Java code not to compile! E.g:
[code]
// Generated 2007/04/18 09:53:07 by Hibernate Tools 3.2.0.b9
/**
* ActiveEndpoint generated by hbm2java
*/
public class ActiveEndpoint implements java.io.Serializable {
private int serviceId;
private Switch switch;
public ActiveEndpoint() {
}
public ActiveEndpoint(int serviceId, Switch switch) {
this.serviceId = serviceId;
this.switch = switch;
}
...
// Generated 2007/04/18 09:53:07 by Hibernate Tools 3.2.0.b9
/**
* Switch generated by hbm2java
*/
public class Switch implements java.io.Serializable {
private int id;
private String name;
...
[/code]
Explicitly forcing the name to something else in hibernate.reveng.xml (e.g. Switch -> CTISwitch) does not help - the field name remains the same even if the class name changes.
--
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