[Hibernate-JIRA] Created: (HHH-5004) Specifying entity access type at class level and then redundantly again on id field or getId() causes EntityManagerFactory configuration failure
by Jesse Hutton (JIRA)
Specifying entity access type at class level and then redundantly again on id field or getId() causes EntityManagerFactory configuration failure
------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-5004
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5004
Project: Hibernate Core
Issue Type: Bug
Components: annotations, entity-manager
Affects Versions: 3.5.0-CR-2
Environment: I'm developing on Fedora 12 64bit version. java version: Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Reporter: Jesse Hutton
Priority: Minor
Attachments: testHibernate.tar.gz
If you annotation an entity class with @Access and either AccessType.FIELD or AccessType.PROPERTY and then repeat the same respective access annotation for identifier of the class, hibernate will not be able to find the identifier. An example stack trace is:
javax.persistence.PersistenceException: [PersistenceUnit: testhibernate] Unable to configure EntityManagerFactory
...
Caused by: org.hibernate.AnnotationException: No identifier specified for entity: com.mycompany.testhibernate.Foo
...
To annotate a class as such is clearly redundant, but it doesn't seem like it should really cause this error. I happened to have discovered it while experimenting with different access type options in JPA 2 using EclipseLink, forgetting to remove an access type annotation to the getId() method of my entity, and then eventually switching JPA providers to Hibernate. Under EclipseLink, there was no problem with the redundant annotations.
Attached is a sample test app illustrating the problem. It has access PROPERTY specified, but the error occurs with FIELD just the same.
--
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, 7 months
[Hibernate-JIRA] Created: (HHH-5270) Oracle Error ORA-01719 on @ManyToMany associations with @FilterJoinTable annotation
by Nico Mack (JIRA)
Oracle Error ORA-01719 on @ManyToMany associations with @FilterJoinTable annotation
-----------------------------------------------------------------------------------
Key: HHH-5270
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5270
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Environment: Hibernate 3.4.0GA (shipped with JBoss 5.1GA) Oracle 11R2 Standard Edition
Reporter: Nico Mack
I have an User EJB Bean who can be assigned via a relation table any number of roles. The following mapping in my User Bean
@ManyToMany(fetch = FetchType.LAZY)
@FilterJoinTable(name = "contextFilter", condition = "context_id = :contextId OR context_id IS NULL")
@JoinTable(name = "rel_user_role", schema = "usermanagement",
joinColumns = {@JoinColumn(name = "user_id")},
inverseJoinColumns = {@JoinColumn(name = "role_id")})
public Set <Role> getRoles()
{
return m_Roles;
}
results in the following query being generated:
select roles0_.user_id as user4_1_,
roles0_.role_id as role3_1_,
role1_.id as id5_0_,
role1_.created as created5_0_,
role1_.creator as creator5_0_,
role1_.modified as modified5_0_,
role1_.modifier as modifier5_0_,
role1_.description as descript4_5_0_,
role1_.name as name5_0_
from usermanagement.rel_user_role roles0_,
usermanagement.role role1_
where roles0_.role_id=role1_.id(+) and roles0_.context_id = ? OR roles0_.context_id IS NULL and roles0_.user_id=?
which in turn causes the following oracle error:
java.sql.SQLException: ORA-01719: outer join operator (+) not allowed in operand of OR or IN
--
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, 7 months
[Hibernate-JIRA] Created: (HCANN-24) @PrimaryKeyJoinColumn and @ForeignKey(name = "FOREIGN_FOOBAR") don't work for InheritanceType.JOINED
by Marcin Cinik (JIRA)
@PrimaryKeyJoinColumn and @ForeignKey(name = "FOREIGN_FOOBAR") don't work for InheritanceType.JOINED
----------------------------------------------------------------------------------------------------
Key: HCANN-24
URL: http://opensource.atlassian.com/projects/hibernate/browse/HCANN-24
Project: Hibernate Commons Annotations
Issue Type: Bug
Affects Versions: 3.2.0
Environment: dialect: Oracle10g
Reporter: Marcin Cinik
Attachments: jpr.zip, schema2.ddl
I've got an example where I have two classes: Customer, ValuedCustomer, where ValuedCustomer inherits from Customer. As InheritanceType.JOINED is used here, hibernate will generate a primary key in ValuedCustomer as well as all integrity constraints for that (I use Oracle10g dialect). I would like to give a name to that foreign key in ValuedCustomer (which is also a primary key there), but it's not possible.
In ValuedCustomer I use @PrimaryKeyJoinColumn annotation and @org.hibernate.annotations.Table with foreignKey property set in it. I would like that hibernate hbm2ddl generate foreign key constraint name as indicated in @ForeignKey annotation but it doesn't. It generates random constraint name instead.
I'm attaching example java project and generated schema file.
--
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, 7 months
[Hibernate-JIRA] Created: (HHH-5269) Schema specified in @Table annotation should be passed as a parameter to the SequenceGenerator generate method.
by Nico Mack (JIRA)
Schema specified in @Table annotation should be passed as a parameter to the SequenceGenerator generate method.
---------------------------------------------------------------------------------------------------------------
Key: HHH-5269
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5269
Project: Hibernate Core
Issue Type: Improvement
Components: core
Environment: Hibernate 3.4.0GA (bundled with JBoss5.1GA)
Reporter: Nico Mack
Priority: Minor
In the scope of a recent project built on JBoss5.1GA and using Oracle as a database we came up with the following architecture. Since all our EJBs are going to need an Id, we put the ID property in a class, called CoreEntityBean with the @MappedSuperclass annotation. Here's what the getId method looks like:
@Id
@GeneratedValue(generator="my_gen")
@GenericGenerator(name = "my_gen", strategy = "my_package.TableNameSequenceGenerator")
@Column(name = "id")
public Integer getId() {
return this.Id;
}
All our actual EJBs inherit from this CoreEntityBean, and are mapped using @Table annotations to tables in different schemas:
@Entity
@Table(name = "info", schema = "core")
public class CoreInfo extends CoreEntityBean {
Our custom TableNameSequenceGenerator basically takes the name of the table and adds the suffix "_seq" to determine the name of the sequence for the corresponding table. All sequences have been created beforehand, in the same schema the corresponding table is located.
Here's what the generate method of our TableNameSequenceGenerator looks like:
@Override
public void configure (Type p_Type, Properties p_Parameters, Dialect p_Dialect) throws MappingException
{
String l_TableName;
String l_SequenceName;
String l_SchemaName;
l_SequenceName = p_Parameters.getProperty(SequenceGenerator.SEQUENCE);
if ((l_SequenceName == null) || (l_SequenceName.length() == 0))
{
l_TableName = p_Parameters.getProperty(PersistentIdentifierGenerator.TABLE);
l_SchemaName = p_Parameters.getProperty(PersistentIdentifierGenerator.SCHEMA);
if (l_TableName != null)
{
l_SequenceName = (l_SchemaName != null)?l_SchemaName + "." + l_TableName + "_seq":l_TableName + "_seq";
p_Parameters.setProperty(SequenceGenerator.SEQUENCE, l_SequenceName);
m_Logger.log(Level.INFO, "Sequence Name = " + l_SequenceName);
}
}
super.configure (p_Type,p_Parameters,p_Dialect);
}
When single-stepping through the generate method, we came to realize that the SCHEMA property was never set and as a consequence the db sequences are not found. I'm not sure whether this issue has already been fixed in a later version or not. If not, I thought it would be useful to add the schema to the properties passed to the SequenceGenerator.
--
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, 7 months
[Hibernate-JIRA] Created: (HV-293) Annotation processor fails in Eclipse when evaluating custom constraints not defined in the current project
by Gunnar Morling (JIRA)
Annotation processor fails in Eclipse when evaluating custom constraints not defined in the current project
-----------------------------------------------------------------------------------------------------------
Key: HV-293
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-293
Project: Hibernate Validator
Issue Type: Bug
Affects Versions: 4.1.0-Beta-1
Reporter: Gunnar Morling
Assignee: Hardy Ferentschik
In certain situations the AP fails when being integrated in Eclipse with the following exception:
java.lang.AssertionError: Class org.hibernate.validator.constraints.impl.LengthValidator specified in @Constraint.validatedBy doesn't implement ConstraintValidator.
at org.hibernate.validator.ap.util.ConstraintHelper.getConstraintValidatorSuperType(ConstraintHelper.java:497)
at org.hibernate.validator.ap.util.ConstraintHelper.getSupportedType(ConstraintHelper.java:426)
at org.hibernate.validator.ap.util.ConstraintHelper.getSupportedTypes(ConstraintHelper.java:402)
at org.hibernate.validator.ap.util.ConstraintHelper.checkCustomConstraint(ConstraintHelper.java:356)
at org.hibernate.validator.ap.util.ConstraintHelper.checkConstraint(ConstraintHelper.java:295)
at org.hibernate.validator.ap.ConstraintAnnotationVisitor.checkConstraintAtField(ConstraintAnnotationVisitor.java:290)
at org.hibernate.validator.ap.ConstraintAnnotationVisitor.visitVariableAsField(ConstraintAnnotationVisitor.java:174)
at org.hibernate.validator.ap.ConstraintAnnotationVisitor.visitVariableAsField(ConstraintAnnotationVisitor.java:45)
at javax.lang.model.util.ElementKindVisitor6.visitVariable(ElementKindVisitor6.java:199)
at org.eclipse.jdt.internal.compiler.apt.model.VariableElementImpl.accept(VariableElementImpl.java:55)
at org.hibernate.validator.ap.ConstraintValidationProcessor.process(ConstraintValidationProcessor.java:84)
at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:139)
at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:121)
at org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:159)
at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(IdeAnnotationProcessorManager.java:134)
at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:810)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:428)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:364)
at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.compile(IncrementalImageBuilder.java:321)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:301)
at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:134)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:265)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:193)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:627)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:170)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:201)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:253)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:309)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:341)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:140)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:238)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
This happens, if the AP examines a constraint annotation, which is not defined in the currently built project itself, but is imported from some other JAR (e.g. @Length from HV):
public class TestModel {
@Length
private String test;
}
The problem occurs, regardless whether the JAR containing the constraint is on the AP classpath or not.
The AP works as expected when running on 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, 7 months
[Hibernate-JIRA] Created: (HHH-4738) getSingleResult returning SQLException in DerbyDialect
by Samuel Halliday (JIRA)
getSingleResult returning SQLException in DerbyDialect
------------------------------------------------------
Key: HHH-4738
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4738
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.5.0-Beta-2
Environment: hibernate 3.5.0-0.2, Glassfish v3, Derby
Reporter: Samuel Halliday
I am encountering problems when issuing getSingleResult queries using the Glassfish v3 "hibernate 3.5.0-0.2". These queries work fine if I use hibernate 3.3.1.GA, or a PostgreSQL backend/dialect. Something between 3.3.1 and 3.5 has therefore introduced this bug.
The queries are along the lines of
[code]
Query q = em.createQuery("SELECT COUNT(s) FROM MyTable s");
Long result = (Long) q.getSingleResult();
[/code]
and
[code]
Query query = em.createQuery("SELECT s FROM MyTable s ORDER BY s.id");
query.setFirstResult(id);
query.setMaxResults(1);
MyTable random = (MyTable) query.getSingleResult();
[/code]
The exception I am seeing is below, when used with (at least) the Java Derby DB. The message is "The column position '1' is out of range. The number of columns for this ResultSet is '0'."
[code]
Caused by: java.sql.SQLException: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.client.am.ColumnMetaData.getColumnType(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.setInt(Unknown Source)
at org.hibernate.loader.Loader.bindLimitParameters(Loader.java:1669)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1594)
at org.hibernate.loader.Loader.doQuery(Loader.java:694)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:257)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
... 42 more
Caused by: org.apache.derby.client.am.SqlException: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
at org.apache.derby.client.am.ColumnMetaData.checkForValidColumnIndex(Unknown Source)
... 49 more
[/code]
--
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, 7 months
[Hibernate-JIRA] Created: (HCANN-21) EnumType speed up in initEnumValues()
by Ondrej Medek (JIRA)
EnumType speed up in initEnumValues()
-------------------------------------
Key: HCANN-21
URL: http://opensource.atlassian.com/projects/hibernate/browse/HCANN-21
Project: Hibernate Commons Annotations
Issue Type: Patch
Affects Versions: 3.1.0.GA, 3.2.x
Environment: Hibernate 3.5.1, Sun JDK 1.6.0_18
Reporter: Ondrej Medek
Priority: Minor
Attachments: EnumType.java.patch
Hi,
I have simplified and sped up the method EnumType.initEnumValues(). See the attached patch.
Tested on Sun JDK 1.6.0_18
Note 1: I do not know, why the author (Emmanuel Bernard?) has used reflection. Maybe the method Class.getEnumConstants() in not implemented by other JREs (IBM, BEA) or he just didn't know this method.?
Note: the method getEnumConstants() in SUN JRE does use the reflection to look for method "values()", too, but it's results are cached, so the second call to the getEnumConstants() is fast. And because the results are cached inside the Enum class itself, it does not cause any memory leaks like HHH-4317.
--
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, 7 months