[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, 7 months
[Hibernate-JIRA] Created: (HHH-5730) Sub-classes of parent may have different id column but Hibernate does not support it!!!!!
by Colbert Philippe (JIRA)
Sub-classes of parent may have different id column but Hibernate does not support it!!!!!
-----------------------------------------------------------------------------------------
Key: HHH-5730
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5730
Project: Hibernate Core
Issue Type: Improvement
Reporter: Colbert Philippe
In my current project, I am in a situation where I have two classes with a lot of common attributes. So I created a common parent-class to hold the common attributes and I created the two subclasses from the parent, each with it's own id attribute (with different column names). Herein lies the problem.
The way the inheritance strategy is implemented under Hibernate native XML meta-data, having different id columns for the subclasses is not possible. The xml schema will not allow it. I understand the reasoning behind forcing subclasses in a inheritance hierarchy to have the same id column. But obviously, there are some situations, like mine, where we want different id column for sub-classes. My complain is that Hibernate should allow subclasses of a parent-class to have different id column.
Incidentally, I also used JPA-2 under Hibernate. The specification for JPA-2 allow for what I stated above. I like the way parent and subclasses feature is implemented in JPA-2. It's simple, intuitive and modular. .
--
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-5709) JPA Metamodel: EntityType.getName != @Entity.name
by Tomasz Blachowicz (JIRA)
JPA Metamodel: EntityType.getName != @Entity.name
-------------------------------------------------
Key: HHH-5709
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5709
Project: Hibernate Core
Issue Type: Bug
Components: metamodel
Affects Versions: 3.6.0
Reporter: Tomasz Blachowicz
I was working recently on the implementation that uses JPA2 meta-model. It was rather surprise to me when I found out that name of the entity on {{EntityType}} is different than name of the entity specified with {{@Entity}} annotation.
The specification is not explicit about the entity names, so it could be interpreted differently, but I think it is reasonable to implicitly assume that entity name specified with {{@Entity}} is used as entity name with JPA2 meta-model.
{quote}
*10.1 Entity*
The {{Entity}} annotation specifies that the class is an entity. This annotation is applied to the entity
class.
The {{name}} annotation element specifies the entity name. If the {{name}} element is not specified, the entity
name defaults to the unqualified name of the entity class. This name is used to refer to the entity in queries.
{code:java}
@Documented @Target(TYPE) @Retention(RUNTIME)
public @interface Entity {
String name() default "";
}
{code}
{quote}
I know that in Hibernate the entity name if FQN of persistent class and the abbreviated name (without the package) can be *only* used within the HQL queries. I guess this was OK prior JPA2 when there was no such think like meta-model.
This topic has been already discussed several times, but I couldn't find any discussion in the context of JPA meta-model, thus I've decided to create a new ticket. The other issues related to this topic are: HHH-4375, HHH-2597 and HHH-4465.
--
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: (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, 7 months
[Hibernate-JIRA] Created: (HHH-5728) LazyInitializationException even when session is open
by Pushkar Prakash (JIRA)
LazyInitializationException even when session is open
-----------------------------------------------------
Key: HHH-5728
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5728
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.6
Environment: Hibernate 3.2.6 GA
Database: mysql-5.1.36
Jdbc driver: mysql connector java 5.1.10
OS: Win XP Pro
Reporter: Pushkar Prakash
Attachments: test case.zip
The test case implements a Many-One association (Employee - Department).
After loading a department I access the employees collections.
When I call the Set.iterator() method on the employees collection implemented as Set Hibernate
throws LazyInitializationException.
This happens whether I specify the inverse="true" on the <set> element in the mapping file or not.
Here is the complete stack trace:
Hibernate: select department0_.departmentId as departme1_1_, department0_.location as location1_ from Department department0_ where department0_.departmentId=1
Employees in department: 1
Hibernate: select employees0_.deptId as deptId1_, employees0_.emp_id as emp1_1_, employees0_.emp_id as emp1_0_0_, employees0_.fname as fname0_0_, employees0_.lname as lname0_0_, employees0_.phone as phone0_0_, employees0_.deptId as deptId0_0_ from employee employees0_ where employees0_.deptId=?
Nov 11, 2010 9:18:29 AM org.hibernate.LazyInitializationException <init>
SEVERE: illegal access to loading collection
org.hibernate.LazyInitializationException: illegal access to loading collection
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:341)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.PersistentSet.hashCode(PersistentSet.java:411)
at Department.hashCode(Department.java:43)
at Employee.hashCode(Employee.java:55)
at java.util.HashMap.put(HashMap.java:418)
at java.util.HashSet.add(HashSet.java:194)
at java.util.AbstractCollection.addAll(AbstractCollection.java:318)
at org.hibernate.collection.PersistentSet.endRead(PersistentSet.java:329)
at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollection(CollectionLoadContext.java:240)
at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:222)
at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:195)
at org.hibernate.loader.Loader.endCollectionLoad(Loader.java:877)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:865)
at org.hibernate.loader.Loader.doQuery(Loader.java:729)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1994)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:63)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:163)
at Test3.main(Test3.java:26)
ex: org.hibernate.LazyInitializationException: illegal access to loading collection
--
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