[Hibernate-JIRA] Created: (HHH-2640) Clob management and deadlock
by Samuel Emangard (JIRA)
Clob management and deadlock
----------------------------
Key: HHH-2640
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2640
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.0.ga
Environment: JDK 1.5, Oracle 10g v2
Reporter: Samuel Emangard
Priority: Trivial
Attachments: Samuel.rar
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
'-//Hibernate/Hibernate Mapping DTD 3.0//EN'
'http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd'>
<hibernate-mapping package="com.toluna.samuel.hibernate.emailtemplate">
<class name="EmailTemplate" table="EmailTemplate">
<id name="id" type="long">
<column name="template_id" not-null="true"/>
<generator class="native"/>
</id>
<property name="name">
<column name="email_name" not-null="false"/>
</property>
<property name="htmlTextClob" type="clob">
<column name="html_Text" not-null="false"/>
</property>
<property name="plainTextClob" type="clob">
<column name="plain_Text" not-null="false"/>
</property>
</class>
</hibernate-mapping>
Extract also of my Java bean:
ublic class EmailTemplate {
private long id;
private String name;
private String plainText = " ";
private String htmlText = " ";
private Clob plainTextClob;
private Clob htmlTextClob;
...
Code of the test case:
Session ss = HibernateUtil.getSessionFactory().getCurrentSession();
//S_LOGGER.debug("Number of current Hibernate sessions: "+ HibernateUtil.getSessionFactory().getStatistics().getSessionOpenCount());
ss.getTransaction().begin();
EmailTemplate et = (EmailTemplate) ss.load(EmailTemplate.class, new Long("299941536982302"));
S_LOGGER.debug(et.getName());
Thread.sleep(5000);
S_LOGGER.debug("BEFORE FLUSH");
ss.flush();
S_LOGGER.debug("AFTER FLUSH");
ss.getTransaction().commit();
The generated SQL :
The load statement is always generated:
/* load com.toluna.samuel.hibernate.emailtemplate.EmailTemplate */ select
emailtempl0_.template_id as template1_0_0_,
emailtempl0_.email_name as email2_0_0_,
emailtempl0_.html_Text as html3_0_0_,
emailtempl0_.plain_Text as plain4_0_0_
from
EmailTemplate emailtempl0_
where
emailtempl0_.template_id=?
....
Depending on the implementation of the getter, the following update statement is generated:
/* update
com.toluna.samuel.hibernate.emailtemplate.EmailTemplate */ update
EmailTemplate
set
email_name=?,
html_Text=?,
plain_Text=?
where
template_id=?
Here is the getter:
Clob getHtmlTextClob() {
//1-
//return Hibernate.createClob(htmlText != null ? htmlText : " ");
//2-
return htmlTextClob;
}
With 1- the update statement is generated
With 2- the update statement is not generated
Why?
Extract of the setter:
void setHtmlTextClob(Clob htmlTextClob) {
this.htmlTextClob = htmlTextClob;
try {
if (htmlTextClob != null) {
htmlText = HibernateUtil.getStringFromClob(htmlTextClob);
//htmlText = "samuel";
} else
htmlText = "";
} catch (SQLException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
I have also another more critical issue which seems tied to the previous:
If I write the following piece of test code instead of the one shown above:
Session ss = HibernateUtil.getSessionFactory().openSession();
//S_LOGGER.debug("Number of current Hibernate sessions: "+ HibernateUtil.getSessionFactory().getStatistics().getSessionOpenCount());
EmailTemplate et = (EmailTemplate) ss.load(EmailTemplate.class, new Long("299941536982302"));
S_LOGGER.debug(et.getName());
Thread.sleep(5000);
S_LOGGER.debug("BEFORE FLUSH");
ss.flush();
S_LOGGER.debug("AFTER FLUSH");
As you can see in this piece of code i do not manage transactions explicitly and in that case my 2 java threads generated update statements which never ended: there was a deadlock on the DB.
During the last test, If I still did not manage transactions explicitly but I modified the getter like that:
Clob getHtmlTextClob() {
return htmlTextClob;
}
Then neither update statements nor deadlock were generated.
I wrote this piece of test code to reproduce deadlock I was facing on my Jonas server.
Could you please help me to understand this behaviour?
Here is anextract of my hibernate.cfg.xml:
<property name="connection.url">jdbc:oracle:thin:@192.168.2.7:1521:tlorcl1</property>
<property name="connection.username">samuel</property>
<property name="connection.password">toluna</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.use_sql_comments">true</property>
<property name="myeclipse.connection.profile">QA</property>
<property name="current_session_context_class">thread</property>
Thanks in advance
Regards
Samuel
--
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, 9 months
[Hibernate-JIRA] Created: (HHH-2710) Cannot specify on-delete="cascade" for a map or a set with just one element
by Gerald Klopp (JIRA)
Cannot specify on-delete="cascade" for a map or a set with just one element
---------------------------------------------------------------------------
Key: HHH-2710
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2710
Project: Hibernate3
Issue Type: Improvement
Components: core
Affects Versions: 3.2.4
Reporter: Gerald Klopp
Priority: Minor
I'd like to specify the on-delete="cascade" attribute for a map or for a set with just one element.
When I try to do this, I get the following exception :
Initial SessionFactory creation failed.org.hibernate.MappingException: only inverse one-to-many associations may use on-delete="cascade"
The on-delete="cascade" attribute can be specified for more complex relationships like one-to-many. But it seems that the case of a simple map or set is not covered.
- Mapping document example:
<hibernate-mapping>
<class name="Document" table="DOCUMENT">
<id name="id" column="DOCUMENT_ID">
<generator class="native" />
</id>
<map name="titles" table="DOCUMENT_TITLE" lazy="false">
<key column="DOCUMENT_ID" on-delete="cascade" />
<index column="LANGUAGE" type="string" />
<element column="TITLE" type="text" not-null="true" />
</map>
<set name="references" table="DOCUMENT_REFERENCE" lazy="false">
<key column="DOCUMENT_ID" on-delete="cascade" />
<element type="string" column="REFERENCE" />
</set>
</class>
</hibernate-mapping>
- Exception stack trace :
Initial SessionFactory creation failed.org.hibernate.MappingException: only inverse one-to-many associations may use on-delete="cascade": Document.references
Exception in thread "main" java.lang.ExceptionInInitializerError
at fr.gklopp.test.hibernate3.util.HibernateUtil.<clinit>(HibernateUtil.java:17)
at fr.gklopp.test.hibernate3.simple.DocumentManager.createAndStoreDocument(DocumentManager.java:23)
at fr.gklopp.test.hibernate3.simple.DocumentManager.main(DocumentManager.java:68)
Caused by: org.hibernate.MappingException: only inverse one-to-many associations may use on-delete="cascade": fr.gklopp.test.hibernate3.simple.Document.references
at org.hibernate.mapping.Collection.validate(Collection.java:267)
at org.hibernate.mapping.Set.validate(Set.java:19)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1106)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
at fr.gklopp.test.hibernate3.util.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 2 more
- Database : Oracle 10
--
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, 9 months
[Hibernate-JIRA] Created: (HHH-2587) There is an attempt to set more parameters on a prepared statement than the latter can hold
by Zied Hamdi (JIRA)
There is an attempt to set more parameters on a prepared statement than the latter can hold
-------------------------------------------------------------------------------------------
Key: HHH-2587
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2587
Project: Hibernate3
Issue Type: Bug
Components: query-sql
Affects Versions: 3.2.3
Environment: JPA through hibernate
Reporter: Zied Hamdi
Priority: Blocker
Attachments: IntoCore.zip
You can directly import the zip content into netBeans 5.5 the just launch: the test is executed at the home page servlet call.
I have an index that doesn't exist : 11 (the total count of columns is 10) :
Hibernate: insert into BasicPersonArchiveEntry (endDate, entryPerformer_revision, entryPerformer_id, lastOccurence, note, startDate, source_revision, source_id, revision, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
could not bind value '0' to parameter: 11; Invalid argument: parameter index 11 is out of range.
SQL Error: -99999, SQLState: null
Invalid argument: parameter index 11 is out of range.
Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not insert: [com.homeservices.model.impl.BasicPersonArchiveEntry]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2267)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:52)
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:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:516)
at com.sun.enterprise.distributedtx.J2EETransaction.commit(J2EETransaction.java:395)
at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:357)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3653)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3431)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1247)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:192)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:118)
at $Proxy49.create(Unknown Source)
at tests.entities.TestArchiveServlet.processRequest(TestArchiveServlet.java:46)
at tests.entities.TestArchiveServlet.doGet(TestArchiveServlet.java:61)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:278)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)
at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
Caused by: org.apache.derby.client.am.SqlException: Invalid argument: parameter index 11 is out of range.
at org.apache.derby.client.am.PreparedStatement.checkForValidParameterIndex(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.checkSetterPreconditions(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.setLong(Unknown Source)
at org.hibernate.type.LongType.set(LongType.java:42)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:116)
at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:284)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2008)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2243)
... 46 more
EJB5018: An exception was thrown during an ejb invocation on [ArchivableFacadeStatelessBean]
javax.ejb.EJBException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.
--
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, 9 months
[Hibernate-JIRA] Created: (HHH-2460) Multiple object creates on HQL select causes "unexpected token: ,"
by Steve Mayhew (JIRA)
Multiple object creates on HQL select causes "unexpected token: ,"
------------------------------------------------------------------
Key: HHH-2460
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2460
Project: Hibernate3
Type: Bug
Components: query-hql
Versions: 3.1.2
Environment: MySQL
Reporter: Steve Mayhew
When executing this query:
select new java.lang.String('test1'), new java.lang.String('test2')
from SomeMappedClass
You get a syntax error. It does not matter what is in the from clause, result is always the same.
[2007-03-01 16:51:29,349] [ERROR:org.hibernate.hql.PARSER] [] - line 1:37: unexpected token: ,
[2007-03-01 16:51:29,365] [DEBUG:org.hibernate.hql.ast.AST] [] - --- HQL AST ---
\-[QUERY] 'query'
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: , near line 1, column 37 [select new java.lang.String('test1'), new java.lang.String('test2')
from SomeMappedClass
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:244)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:155)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
at net.jvnet.dev.hqe.ThreadHQLQueryExecution.run(Unknown Source)
Caused by: line 1:37: unexpected token: ,
at org.hibernate.hql.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1145)
at org.hibernate.hql.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:702)
at org.hibernate.hql.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:296)
at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:159)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:238)
... 9 more
--
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, 9 months
[Hibernate-JIRA] Created: (ANN-472) @UniqueConstraint declaration is not friendly towards inheritance or reflection
by Ted Bergeron (JIRA)
@UniqueConstraint declaration is not friendly towards inheritance or reflection
-------------------------------------------------------------------------------
Key: ANN-472
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-472
Project: Hibernate Annotations
Type: Improvement
Versions: 3.2.0.ga
Environment: Hibernate 3.2 GA
Reporter: Ted Bergeron
The current way to define a composite unique constraint is limiting.
@Table(name="tbl_sky",
uniqueConstraints = {@UniqueConstraint(columnNames={"month", "day"})}
)
Suppose I have an abstract base class called A that gives me Id and Name, subclassed by abstract class B that gives me Customer. Then I have many concrete classes that subclass B. For all of these, I'd want the combination of Name and Customer to be unique. As I do not use @Table with abstract base classes, I currently have to repeat: uniqueConstraints = {@UniqueConstraint(columnNames={"name", "customer_id"})} on all concrete classes.
If we had an alternate way to define these constraints at the property level (as XDoclet did with hibernate 2), I could define this in the base classes and inherit the constraint declaration.
The other need is that I would like to use reflection to scan the properties and apply proper validations in the view layer. With @Column(unique = true) this is easy to do. The view layer makes an AJAX call and all is well. For a composite constraint, it does not work well currently.
--
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, 10 months
[Hibernate-JIRA] Created: (HHH-2692) Insert Into Select command doesn't allow named parameter as select output (insert input)
by John Aylward (JIRA)
Insert Into Select command doesn't allow named parameter as select output (insert input)
----------------------------------------------------------------------------------------
Key: HHH-2692
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2692
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.4.sp1
Environment: Hibernate 3.2.4.sp1 with Annotations 3.3.0 And Validator 3.0.0
MySQL 5.0.42
Reporter: John Aylward
receive exception:
org.hibernate.QueryException: number of select types did not match those for insert [INSERT INTO ProviderInvoiceLineItem (amount,billingAccount,circuit,description,invoice,type) SELECT pili.amount, pili.billingAccount, pili.circuit, pili.description, :newInvoice, pili.type FROM com.cicat.bedrock.billing.model.ProviderInvoiceLineItem pili WHERE pili.invoice = :oldInvoice]
Idea is to copy all line items from one invoice to another. In other words, only difference between data should be the invoice. easiest way to do this is with "insert into" command and passing parameter of changed value.
* Trying to cast named parameter (:newInvoice) caused parsing error
* Trying to replace invoice with invoice_id and repacing :newInvoice with actual invoice id resulted in a "property 'invoice_id' not found" exception
Should be able to set a value through a named parameter
--
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, 10 months