[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-2097) LAZY property results in org.hibernate.TransientObjectException after merge
by Reto Urfer (JIRA)
LAZY property results in org.hibernate.TransientObjectException after merge
---------------------------------------------------------------------------
Key: HHH-2097
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2097
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.cr4
Environment: Hibernate3.2 cr4 with Annotations cr2 and EntityManager cr2, Oracle10g R2, WindowsXP
Reporter: Reto Urfer
Priority: Critical
Attachments: BugLazyPropertyMerge.zip
Entity1 has a property e2 which references Entity2. This property is defined as follows.
@ManyToOne(fetch = FetchType.LAZY, optional = false)
private Entity2 e2;
If you have an instance e1 of Entity1 which has not initialized property e2 and you merge e1 to the EntityManager within a transaction, then you get the following exception during commit:
Exception in thread "main" javax.persistence.RollbackException: Error while commiting the transaction
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:63)
at com.test.Test.main(Test.java:42)
Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.test.Entity1.e2 -> com.test.Entity2
at org.hibernate.engine.CascadingAction$9.noCascade(CascadingAction.java:350)
at org.hibernate.engine.Cascade.cascade(Cascade.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:130)
at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:121)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:53)
... 1 more
I added a small Testproject to reproduce this bug.
--
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
14 years, 1 month
[Hibernate-JIRA] Created: (HHH-2319) StatelessInterceptor
by Max Rydahl Andersen (JIRA)
StatelessInterceptor
--------------------
Key: HHH-2319
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2319
Project: Hibernate3
Type: New Feature
Components: core
Versions: 3.2.1
Reporter: Max Rydahl Andersen
It would make sense to have an Interceptor for StatelessSession to solve the following usecases:
Log/adjust SQL: onPrepareStatement
Proper entityname handling: instantiate/getEntity
Maybe also tx interaction: afterTransationBegin/beforeTransactionCompletion/afterTransactionCompletion
Technically it could be solved by just allowing to pass in a normal interceptor to a StatelessSession and just
document that the state oriented callbacks will not be called. Alternatively we can create a StatelessInterceptor that
only implement the releavant methods and wrap that instance into an internal Interceptor.
--
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
14 years, 2 months
[Hibernate-JIRA] Created: (HHH-2007) Hibernate doesn't support optional one-to-one associations
by Andrei Iltchenko (JIRA)
Hibernate doesn't support optional one-to-one associations
----------------------------------------------------------
Key: HHH-2007
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2007
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.cr2
Reporter: Andrei Iltchenko
Hibernate doesn't properly support optional one-to-one associations, e.g. Person (0..1) -- (0..1) Passport.
The Hibernate books and reference all talk of two ways of mapping one-to-one associations:
1. using a many-to-one fk association with a unique constraint on the fk;
2. using a pk association.
the trouble with both of them is that they enforce the mandatory property of an association end, which sometimes is not desirable. The first way enforces the mandatory property with the uniqueness constraint on the fk, the other by using the fact that one table's pk is its fk.
I tried to see if I could adapt the 1st way of representing one-to-ones to
support optional association ends. What I did was simply remove the unique and not null constrains from DDL generated (without removing it it would be impossible to have a Person record that doesn't reference a Passport record):
from
CREATE TABLE Person (
PassUniqueId VARCHAR (32) NOT NULL,
version INTEGER NOT NULL,
uniqueId VARCHAR (32) NOT NULL,
name VARCHAR (40) NULL,
PRIMARY KEY (uniqueId),
UNIQUE(PassUniqueId),
FOREIGN KEY (PassUniqueId) REFERENCES Passport (uniqueId)
);
to
CREATE TABLE Person (
PassUniqueId VARCHAR (32) NULL,
version INTEGER NOT NULL,
uniqueId VARCHAR (32) NOT NULL,
name VARCHAR (40) NULL,
PRIMARY KEY (uniqueId),
FOREIGN KEY (PassUniqueId) REFERENCES Passport (uniqueId)
);
but leave the uniqueness attribute in the mapping file:
<many-to-one
name="pass"
class="application.business.logic.Passport"
cascade="save-update,merge"
unique="true"
>
<column name="PassUniqueId"/>
</many-to-one>
The resulting solution worked fine and I was able to create instances of Person not linked to a Passport. However Hibernate didn't succed in keeping the association from degrading into a many-to-one. It enabled me to create two Persons linked with the same Passport:
PASSUNIQUEID | VIRSION | UNIQUEID | Name
================================================
0d8b3919fffff | 1 | 0d5fb1dcfff | John
0d8b3919fffff | 0 | 10fd07bdfff | Sam
A subsequent attempt at retrieving such Persons with Hibernate failed:
org.hibernate.HibernateException: More than one row with the given identifier was found: 0d8b3919ffffffd60151e135b6da0164, for class: application.business.logic.Passport.
Hibernate should be able to impose the single end property of such associations without relying on the underlying RDBMS engine and never allow them to degrade to many-to-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
14 years, 2 months
[Hibernate-JIRA] Created: (HHH-2228) ant eg fails - bad release notes quick start
by Brian Brooks (JIRA)
ant eg fails - bad release notes quick start
--------------------------------------------
Key: HHH-2228
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2228
Project: Hibernate3
Type: Bug
Components: documentation
Versions: 3.2.0.ga
Environment: hibernate 3.2.0.ga
Microsoft Windows XP [Version 5.1.2600]
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode)
Reporter: Brian Brooks
Priority: Minor
The hibernate 3.2.0.ga release notes
http://sourceforge.net/project/shownotes.php?release_id=455849&group_id=4...
read as
Get Up And Running Quick
------------------------
Demo:
(1) copy your JDBC driver to the lib directory
(2) edit etc/hibernate.properties
(3) run "ant eg" or "build eg"
(4) browse the sourcecode in eg/org/hibernate/auction
This directions are incorrect. Below is the ant output if these steps are followed. Also, I had to put junit*.jar and antlr*all*.jar in my ANT_HOME/lib before ant eg would work.
C:\hibernate-3.2>ant eg
Buildfile: build.xml
[taskdef] Could not load definitions from resource clovertasks. It could not b
e found.
eg:
[javac] Compiling 8 source files to C:\hibernate-3.2\build\eg
[javac] C:\hibernate-3.2\eg\org\hibernate\auction\Main.java:10: cannot find
symbol
[javac] symbol : class FetchMode
[javac] location: package org.hibernate
[javac] import org.hibernate.FetchMode;
[javac] ^
[javac] C:\hibernate-3.2\eg\org\hibernate\auction\Main.java:11: cannot find
symbol
[javac] symbol : class FlushMode
[javac] location: package org.hibernate
[javac] import org.hibernate.FlushMode;
[javac] ^
[javac] C:\hibernate-3.2\eg\org\hibernate\auction\Main.java:12: cannot find
symbol
[javac] symbol : class LockMode
[javac] location: package org.hibernate
[javac] import org.hibernate.LockMode;
[javac] ^
....
--
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
14 years, 2 months
[Hibernate-JIRA] Created: (HHH-2131) SYBASE +select for update is showing deadlock because lock is not working properly
by George Thomas (JIRA)
SYBASE +select for update is showing deadlock because lock is not working properly
----------------------------------------------------------------------------------
Key: HHH-2131
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2131
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.1.3
Environment: sybaseASE 12.5.03 in solaris +hibernate3.1.3
Reporter: George Thomas
I am connecting to Sybase database from hibernate.I tried setting locks using while selecting rows
1.session.load(class,id,LOCKMODE.UPGRADE)
2.session.lock(obj,LOCKMODE.UPGRADE)
I am attaching a sample code while updating a field in table fund after selecting it.
{
Fund fund = null;
ClientCredential credential = new ClientCredential("testDatabase", fund);
org.hibernate.Session session = SessionFactoryManager.getSessionFactory(credential).getCurrentSession();
Transaction transaction = session.beginTransaction();
log.info("Run by " + Thread.currentThread().getName());
fund = (Fund) session.get(Fund.class, new Short((short)12), LockMode.UPGRADE);
fund.setLegalEntityOrgId(fund.getLegalEntityOrgId()+1);
transaction.commit();
}
my requirement was that i wanted to do a select for update.I should acquire lock on certain rows and do a matching and if concurrent request comes ,it should wait till transaction is over that is lock is released.
When I went through the hibernate code,the hibernate is making static queries in the beginning while loading session factory.Since we are appending the holdlock during execution,the sybase dialect is not appending.
As a work around I tested with native sql with holdlock but when I test concurrent request using threads its bombing.Its throwing LockAcquisitionException.( Your server command (family id #0, process id #3777) encountered a deadlock situation.).can anyone give a solution to this problem???
org.hibernate.exception.LockAcquisitionException: could not update: [com.citco.aexeo.common.dataaccess.domain.Fund#12]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:84)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2223)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2375)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:91)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:233)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
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:107)
at com.satyam.Testing.doTransaction(Testing.java:103)
at com.satyam.MyRunnable.run(MyRunnable.java:13)
at java.lang.Thread.run(Thread.java:568)
Caused by: com.sybase.jdbc2.jdbc.SybSQLException: Your server command (family id #0, process id #3777) encountered a deadlock situation. Please re-run your command.
at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2636)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1996)
at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:204)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:187)
at com.sybase.jdbc2.jdbc.SybStatement.updateLoop(SybStatement.java:1642)
at com.sybase.jdbc2.jdbc.SybStatement.executeUpdate(SybStatement.java:1625)
at com.sybase.jdbc2.jdbc.SybPreparedStatement.executeUpdate(SybPreparedStatement.java:91)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2205)
... 14 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
14 years, 4 months