[Hibernate-JIRA] Created: (HHH-3305) hbm2ddl: MS SQL Server 2005 defaults to Clustered Index on PK, lets use PRIMARY KEY NONCLUSTERED for hbm2ddl as a more reasonable default
by Jim Doyle (JIRA)
hbm2ddl: MS SQL Server 2005 defaults to Clustered Index on PK, lets use PRIMARY KEY NONCLUSTERED for hbm2ddl as a more reasonable default
-------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-3305
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3305
Project: Hibernate3
Issue Type: Bug
Components: metamodel
Affects Versions: 3.2.1
Reporter: Jim Doyle
In SQL Server 2005, PRIMARY KEY defaults to creating a Clustered Index for the PK column at table creation time.
To confirm this behaviour Please see: http://msdn.microsoft.com/en-us/library/ms188066.aspx
This default behaviour is un-desireable for a number of reasons:
1. No other databases default to a clustered IDX at the PK ; Not DB2, nor Oracle nor MySQL
2. There may only be ONE clustered IDX per table. By using this as a default makes it difficult
for the app developer or DBA to quickly add or change the once-per-table opportunity to use
the cluster to improve query performance.
3. The default cluster index that Microsoft applies seems only to benefit naive SQL server users with
little to no DBA skills. Table insert of new rows onto a Clustered Index PK is always very fast and
while this optimization may be impressive if your problem space is rapidly inserting new data into large tables,
this optimization is often an antipattern to users with more plausible query patterns such as scan by non-primary
key date, numeric amounts or alphabetical data.
4. Defaulting the PK to clustered creates SUBSTANTIAL burden for a DBA when the Clustered Index needs to be removed
from the PK to be deployed on other columns on the table. As an example of the burden that this creates, for EACH TABLE
one must:
- Discover all tables and columns that link back to the table in question through FOREIGN KEY
- Drop all foreign keys
- Drop the PK
- Add the PK back, with NONCLUSTERED
- Put back all the dropped Foreign keys
5. Additional arguments against supporting Microsoft's unusual default is given here:
http://tonesdotnetblog.wordpress.com/2008/05/26/twelve-tips-for-optimisin...
(Please See Section 2: Use Clustered Index).
I propose ANY ONE of the following enhancements to the DDL generator for the SQL Server 2005 Dialect:
1. Change the generated SQL from colname coltype PRIMARY KEY TO colname coltype PRIMARY KEY NONCLUSTERED such that
PK index generate conforms the the usual, sensible defaults of other database products.
2. Use a Properties attribute (i.e. hibernate.hbm2ddl.dialect.mssql.use_non_clustered_pk) that is evaluated at hbm2ddl runtime
that will emit 'NONCLUSTERED' to the PK clause. If this Property is not defined, the hbm2ddl will simply emit PRIMARY KEY as it does
now and MS SQL Server will use its peculiar and annoying default.
--
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
13 years, 5 months
[Hibernate-JIRA] Created: (ANN-758) map key type no longer inferred correctly, throws exception at runtime
by David Mansfield (JIRA)
map key type no longer inferred correctly, throws exception at runtime
----------------------------------------------------------------------
Key: ANN-758
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-758
Project: Hibernate Annotations
Issue Type: Bug
Components: binder
Affects Versions: 3.3.1.GA
Environment: hib. 3.2, annotaions 3.3.1GA, em 3.3.1GA, oracle 10r2, tomcat 5.5, linux, spring 2.0
Reporter: David Mansfield
Attachments: hib-anno-set-map-key-type.patch
after upgrading from annotations 3.3.0GA to 3.3.1GA, my mapped collection (ManyToMany) is broken. i've identified the commit that broke it:
http://fisheye.jboss.com/browse/Hibernate/annotations/trunk/src/java/org/...
The issue is that unless the type is given now expliticly in the @MapKey's @Type, the code now assumes a 'Serializable' type, and attempts to deserialize an object stream from the database column value. the exact exception is:
java.io.StreamCorruptedException: invalid stream header
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:764)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:277)
at org.hibernate.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:252)
at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:209)
at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:240)
at org.hibernate.type.SerializableType.fromBytes(SerializableType.java:82)
at org.hibernate.type.SerializableType.get(SerializableType.java:39)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
...
The fix is simple: if @Type is NOT given in the @MapKey annotation, keep the old behavior which at least tries to set the type, even if it may not work in all situations. The attached patch fixes the problem for me.
In my particular situation, the map key type is a java.lang.Enum. Here's what my annotated property looks like:
@ManyToMany
@JoinTable(
name="chargeback_owner"
,joinColumns=@JoinColumn(name="person_id",referencedColumnName="person_id")
,inverseJoinColumns=@JoinColumn(name="owner_person_id")
)
@MapKey(columns=@Column(name="owner_type_cd"),targetElement=ChargebackOwnerType.class)
@Enumerated(EnumType.STRING)
@Sort(type=SortType.NATURAL)
private SortedMap<ChargebackOwnerType,Person> owners = new TreeMap<ChargebackOwnerType, Person>();
--
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
13 years, 5 months
[Hibernate-JIRA] Created: (HHH-2449) Lazy loading for one-to-one asociations
by jose (JIRA)
Lazy loading for one-to-one asociations
---------------------------------------
Key: HHH-2449
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2449
Project: Hibernate3
Type: New Feature
Components: core
Versions: 3.2.2
Environment: Hibernate 3.2.2
Reporter: jose
After read "Some explanations on lazy loading" and my tests I found a lossing feature in Hibernate (3.2.2).
one-to-one with lazy="proxy"_____________________________________________
Hibernate ALWAYS launch selects to know if one-to-one is null or can be proxied.
one-to-one with lazy="no-proxy"__________________________________________
Instrumentation allows to hibernate modify the getter to allows lazy loading on demand:
* but allways initialize ALL no-proxy relations (with first getter call)
-> must initialize ONLY the requested property
* never auto-initialize FETCH joins, ALWAYS doit on demand (if opened session)
-> must auto-initialize ONLY the FETCHED property
note: Can submit a fix for this? How?
NEW FEATURE: one-to-one with lazy="proxy" without multiple SELECTS______
If Hibernate adds join, for all one-to-one relations, to get the foreign-key of other tables, can check it to create a proxy or null.
note: that hibernate adds joins for hierarchy, why not for one-to-one relations?
This solution avoids:
* 'multiple subselects' after first select
* 'instrumentation' of bytecode
--
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
13 years, 5 months
[Hibernate-JIRA] Created: (HHH-3029) use_sql_commants fails on Derby
by Oleksandr Alesinskyy (JIRA)
use_sql_commants fails on Derby
-------------------------------
Key: HHH-3029
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3029
Project: Hibernate3
Issue Type: Bug
Environment: WinXP, SP2 Java 1.5..0_12, Spring 2.0.7, Hibernate 3.2.5ga, Derby 10.3.2.1
Reporter: Oleksandr Alesinskyy
Activation is use_sql_comments cause SQL exception
/* insert de.ntec.lms.impl.P1Bean
*/ insert
into
P1
(VERSION, CELL_POS, CODE, CELL_ID, PLACE_ID)
values
(?, ?, ?, ?, ?)
2007-12-25 11:46:29,406 WARN org.hibernate.util.JDBCExceptionReporter
SQL Error: -1, SQLState: 42X01
2007-12-25 11:46:29,406 ERROR org.hibernate.util.JDBCExceptionReporter
Syntaxfehler: Encountered "/" at line 1, column 1.
2007-12-25 11:46:29,487 ERROR org.hibernate.event.def.AbstractFlushingEventListener
Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: could not insert: [de.ntec.lms.impl.P1Bean]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2078)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2427)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at de.ntec.lms.impl.PerformanceTest.doMain(PerformanceTest.java:84)
at de.ntec.lms.impl.PerformanceTest.main(PerformanceTest.java:46)
Caused by: java.sql.SQLException: Syntaxfehler: Encountered "/" at line 1, column 1.
at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:185)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:278)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:442)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:93)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:86)
at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:171)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2048)
... 12 more
Caused by: org.apache.derby.client.am.SqlException: Syntaxfehler: Encountered "/" at line 1, column 1.
at org.apache.derby.client.am.Statement.completeSqlca(Unknown Source)
at org.apache.derby.client.net.NetStatementReply.parsePrepareError(Unknown Source)
at org.apache.derby.client.net.NetStatementReply.parsePRPSQLSTTreply(Unknown Source)
at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
... 20 more
Hibernate settings (via Spring)
<property name="manglableMappingResources">
<list>
<value>de/ntec/lms/impl/P1Bean.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.DerbyDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.use_sql_comments">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
</props>
</property>
When use_sql_comments is false all works smoothly.
Failing code
P1Bean p1= new P1Bean();
p1.setCell(1);
p1.setCellPosition(2);
p1.setCode("A");
s.save(p1);
--
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
13 years, 5 months
[Hibernate-JIRA] Created: (HHH-5002) testQuery in org.hibernate.test.legacy.FooBarTest errors running with Ingres dialect
by Ray Fan (JIRA)
testQuery in org.hibernate.test.legacy.FooBarTest errors running with Ingres dialect
------------------------------------------------------------------------------------
Key: HHH-5002
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5002
Project: Hibernate Core
Issue Type: Bug
Components: query-sql, testsuite
Affects Versions: 3.5.0-CR-2
Environment: Hibernate 3.5.0-CR-2, Ingres 9.3.1 (int.lnx/106), IngresDialect
Reporter: Ray Fan
Attachments: legacy.FooBarTest.zip
testQuery in org.hibernate.test.legacy.FooBarTest errors with an exception whilst using IngresDialect
{noformat}
<error message="could not execute query" type="org.hibernate.exception.GenericJDBCException">org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2276)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2151)
at org.hibernate.loader.Loader.list(Loader.java:2146)
at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:936)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1258)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.test.legacy.FooBarTest.testQuery(FooBarTest.java:388)
Caused by: com.ingres.gcf.util.SqlEx: An internal error prevents further processing of this query.
Associated error messages which provide more detailed information about the problem can be found in the error log, II_CONFIG:errlog.log
at com.ingres.gcf.jdbc.DrvObj.readError(Unknown Source)
at com.ingres.gcf.jdbc.DrvObj.readResults(Unknown Source)
at com.ingres.gcf.jdbc.RsltFtch.preLoad(Unknown Source)
at com.ingres.gcf.jdbc.RsltCurs.preLoad(Unknown Source)
at com.ingres.gcf.jdbc.RsltCurs.<init>(Unknown Source)
at com.ingres.gcf.jdbc.JdbcPrep.exec(Unknown Source)
at com.ingres.gcf.jdbc.JdbcPrep.executeQuery(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1832)
at org.hibernate.loader.Loader.doQuery(Loader.java:719)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:271)
at org.hibernate.loader.Loader.doList(Loader.java:2273)
... 37 more
</error>
{noformat}
--
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
13 years, 5 months