[Hibernate-JIRA] Created: (HV-374) NoSuchMethodError on Persistence.getPersistenceUtil() on WebLogic 10.3.3 (11g)
by Vitaly Polonetsky (JIRA)
NoSuchMethodError on Persistence.getPersistenceUtil() on WebLogic 10.3.3 (11g)
------------------------------------------------------------------------------
Key: HV-374
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-374
Project: Hibernate Validator
Issue Type: Bug
Affects Versions: 4.1.0.Final
Environment: WebLogic 10.3.3 (11g)
Reporter: Vitaly Polonetsky
Assignee: Hardy Ferentschik
The latest WebLogic comes with hybrid configuration of JPA 1.0 with some features of JPA 2.0:
https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&doctype=FAQ...
This causes a problem with the way Hibernate Validator checks for existence of JPA 2.0:
org.hibernate.validator.engine.resolver.DefaultTraversableResolver.detectJPA() checks for existance of javax.persistence.PersistenceUtil class (which exists only in JPA 2.0), but org.hibernate.validator.engine.resolver.JPATraversableResolver will not use it directly, instead it will use javax.persistence.Persistence.getPersistenceUtil() (the class exists for JPA 1.0, but the method is available only at JPA 2.0).
This check is good for situations where either full JPA 1.0 or full 2.0 implementation is available, but is cases like we have in WebLogic it leads to an Error:
java.lang.NoSuchMethodError: javax.persistence.Persistence.getPersistenceUtil()Ljavax/persistence/PersistenceUtil;
at org.hibernate.validator.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:62)
at org.hibernate.validator.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:94)
at org.hibernate.validator.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:47)
at org.hibernate.validator.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:757)
at org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:324)
at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForRedefinedDefaultGroup(ValidatorImpl.java:273)
at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:256)
at org.hibernate.validator.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:210)
at org.hibernate.validator.engine.ValidatorImpl.validate(ValidatorImpl.java:119)
...
I would suggest a possible way to overcome this situation in Hibernate Validator:
To check for existence of JPA 2.0, check the existence of Persistence.getPersistenceUtil() method, instead of checking for the existence of PersistenceUtil class. This will disable the use of JPA 2.0 features inside HV when the method is not available.
--
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
15 years, 5 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
15 years, 5 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
15 years, 5 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
15 years, 5 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
15 years, 5 months