[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
13 years, 7 months
[Hibernate-JIRA] Created: (HBX-1042) Make DocHelper robust against failing buildSettings()
by Arnout Engelen (JIRA)
Make DocHelper robust against failing buildSettings()
-----------------------------------------------------
Key: HBX-1042
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1042
Project: Hibernate Tools
Issue Type: Improvement
Components: hbm2doc
Reporter: Arnout Engelen
Attachments: dochelper.diff.txt
DocHelper calls cfg.buildSettings(). to get the Dialect, default catalog name and default schema name.
However, cfg.buildSettings() may fail with a HibernateException (example below).
It would be nice to have DocHelper handle this more gracefully. Attached is a simple patch that does this.
(background: I'd like to use the Configuration I'm getting from a Spring LocalSessionFactoryBean, which after initial creation leaves its LocalDataSourceConnectionProvider in a state that yiels a HibernateException when calling 'configure()' on it, which buildSettings() does. Because of this issue, I cannot use the DocExporter for my Spring-based hibernate configurations)
--
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, 7 months
[Hibernate-JIRA] Created: (HHH-5453) ByteCodeHelper.readByteCode won't load classes bigger than a constant size
by Marcos Pernambuco (JIRA)
ByteCodeHelper.readByteCode won't load classes bigger than a constant size
--------------------------------------------------------------------------
Key: HHH-5453
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5453
Project: Hibernate Core
Issue Type: Patch
Components: core
Affects Versions: 3.6.0.Beta2, 3.6.0.Beta1, 3.5.4, 3.5.3, 3.5.2, 3.5.1, 3.5.0-Final, 3.5.0-CR-2, 3.5.0-CR-1, 3.5.0-Beta-4, 3.5.0-Beta-3, 3.5.0-Beta-2, 3.5.0.Beta-1, 3.3.2, 3.3.1
Reporter: Marcos Pernambuco
Attachments: ByteCodeHelper.readByteCode.svn.diff
Although it is unlikely that a class will have more than 409600 bytes, ByteCodeHelper.readByteCode() will fail in this case.
The programmer's intention was clear: handle any file size; but he or she forgot to add a call to inputStream.read() at the end of the loop
...
r = inputStream.read( buffer );
while ( r >= buffer.length ) {
byte[] temp = new byte[ classBytes.length + buffer.length ];
System.arraycopy( classBytes, 0, temp, 0, classBytes.length );
System.arraycopy( buffer, 0, temp, classBytes.length, buffer.length );
classBytes = temp;
// THERE SHOULD BE A "r = inputStream.read( buffer )" HERE
}
...
--
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, 8 months
[Hibernate-JIRA] Created: (HV-361) Only one check constraint is generated when @Min and @Max annotation is used on a single field
by Jens Schauder (JIRA)
Only one check constraint is generated when @Min and @Max annotation is used on a single field
----------------------------------------------------------------------------------------------
Key: HV-361
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-361
Project: Hibernate Validator
Issue Type: Bug
Affects Versions: 4.1.0.Final
Environment: Hibernate Core 3.5.5-Final; Hibernate Annotation 3.5.5-Final; Oracle10gDialect
Reporter: Jens Schauder
Assignee: Hardy Ferentschik
Attachments: checkConstraintTest.zip
When generating DDL create scripts fields which have a @Max and @Min annotation only get check constraints for the @Max constraint.
Example entity class:
{noformat}
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
@Entity
public class TestClass {
@Id
private Long id;
@Max(10)
@Min(2)
private Integer min2Max10;
@Max(99999)
@Min(0)
private Integer min0max99;
}
{noformat}
Code used for generating the DDL script:
{noformat}
public static void main(String[] args) {
AnnotationConfiguration config = new AnnotationConfiguration()
.addAnnotatedClass(TestClass.class);
final String[] script = config
.generateSchemaCreationScript(new Oracle10gDialect());
for (String string : script) {
System.out.println(string);
}
}
{noformat}
Resulting output:
{noformat}
create table TestClass (id number(19,0) not null, min0max99 number(10,0) check (min0max99>=0), min2Max10 number(10,0) check (min2Max10>=2), primary key (id))
{noformat}
I tried to locate the problem in the hibernate source code. It might be in the {{applyConstraints}} Method of the {{TypeSafeActivator}} class. It seems that it just *sets* constraints on a column and doesn't make an attempt to merge a min-constraint and a max-constraint into one check constraint.
There is also a related Forum thread regarding this issue: https://forum.hibernate.org/viewtopic.php?f=9&t=1006740
Find the zipped sources for a little test project attached
--
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, 8 months
[Hibernate-JIRA] Created: (HV-390) Boolean composition of constraints
by Federico Mancini (JIRA)
Boolean composition of constraints
----------------------------------
Key: HV-390
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-390
Project: Hibernate Validator
Issue Type: New Feature
Components: engine
Reporter: Federico Mancini
Assignee: Hardy Ferentschik
By adding a built-in annotation @Bool (or some other name) with element values OR, ALLFALSE and AND (which would be the default) it would be possible to
compose constraints in a boolean fashion.
For example:
//Specify that at least one of the patterns must match
@Bool(OR)
@List({@Pattern(regexp="pat1"),@Pattern(regexp="pat2"),@Pattern(regexp="pat3"),@Pattern(regexp="pat4")})
@interface WhiteList{..}
//Specify that none of the patterns must match
@Bool(ALLFALSE)
@List({@Pattern(regexp="pat1"),@Pattern(regexp="pat2"),@Pattern(regexp="pat3"),@Pattern(regexp="pat4")})
@interface BlackList{..}
//At least on valid contact method must match
@Bool(OR)
@Email
@Address
@Phone
@interface ContactDetails{...}
This would greatly increase the type of new constraints that can be defined just by reusing some existing ones.
Possible extensions might be for example further operators like XOR (meaning exactly one of the constraints must hold) or similar.
It seems like it is possible to implement this feature by adding very little code to just a couple of classes, and adding the new @Bool annotation to the API.
--
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, 8 months