[Hibernate-JIRA] Created: (HHH-5917) Envers doesnt track all columns anymore
by Slawek Garwol (JIRA)
Envers doesnt track all columns anymore
---------------------------------------
Key: HHH-5917
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5917
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.6.1
Environment: WinXP, Oracle
Reporter: Slawek Garwol
Envers doesnt track all columns anymore:
Audited table:
create table CREW_DAILY_STATISTICS (
CREW_DAILY_STATISTICS_ID number(10,0) not null,
STAFF_NUM varchar2(12 char) not null,
STATISTICS_DATE timestamp not null,
CREDIT_TIME number(5,0) not null,
DUTY_TIME number(5,0) not null,
FLYING_TIME number(5,0) not null,
NIGHT_FLYING_TIME number(5,0) not null,
NON_STD_FLYING_TIME number(5,0) not null,
DAYS_OFF_COUNT number(5,0) not null,
LEAVE_COUNT number(5,0) not null,
BLANK_DAY_COUNT number(5,0) not null,
primary key (CREW_DAILY_STATISTICS_ID),
unique (STAFF_NUM, STATISTICS_DATE)
);
AUD table in Hibernate 3.6.0:
create table CREW_DAILY_STATISTICS_AUD (
CREW_DAILY_STATISTICS_ID number(10,0) not null,
REV number(19,0) not null,
REVTYPE number(3,0),
STAFF_NUM varchar2(12 char),
STATISTICS_DATE timestamp,
CREDIT_TIME number(5,0),
DUTY_TIME number(5,0),
FLYING_TIME number(5,0),
NIGHT_FLYING_TIME number(5,0),
NON_STD_FLYING_TIME number(5,0),
DAYS_OFF_COUNT number(5,0),
LEAVE_COUNT number(5,0),
BLANK_DAY_COUNT number(5,0),
primary key (CREW_DAILY_STATISTICS_ID, REV)
);
AUD table in Hibernate 3.6.1:
create table CREW_DAILY_STATISTICS_AUD (
CREW_DAILY_STATISTICS_ID number(10,0) not null,
REV number(19,0) not null,
REVTYPE number(3,0),
primary key (CREW_DAILY_STATISTICS_ID, REV)
);
--
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, 3 months
[Hibernate-JIRA] Created: (HHH-6177) Envers - problem with mapping relation when using mixed inheritance strategy
by Michał Skowronek (JIRA)
Envers - problem with mapping relation when using mixed inheritance strategy
----------------------------------------------------------------------------
Key: HHH-6177
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6177
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 4.0.0.Alpha2
Environment: 3.6.0.Final
Oracle10g
Reporter: Michał Skowronek
Attachments: MixedInheritanceStrategies.patch
For the mapping like that:
<hibernate-mapping>
<class abstract="true" name="AbstractActivity"
table="ACTIVITY">
<id name="id" type="integer">
<generator class="assigned"/>
</id>
<discriminator column="ACTIVITY_TYPE" type="string" length="20"/>
<property name="sequenceNumber" type="int" not-null="true"/>
<subclass abstract="true"
name="AbstractCheckActivity">
<join table="ACTIVITY_CHECK">
<key foreign-key="FK_CHKACT_ACT" not-null="true" column="ACTIVITY_ID"/>
<property name="durationInMinutes" type="int" not-null="true" column="DURATION_IN_MINUTES"/>
<many-to-one name="relatedActivity"
cascade="merge"
foreign-key="FK_CHKACT_RELACT"
class="AbstractActivity"
lazy="proxy">
<column name="RELATED_ACTIVITY_ID" not-null="false"/>
</many-to-one>
</join>
<subclass name="CheckInActivity"
discriminator-value="CHECK_IN"/>
</subclass>
<subclass name="NormalActivity"
discriminator-value="NORMAL"/>
</class>
</hibernate-mapping>
Envers generates improper audit table configuration for AbstractCheckActivity:
<hibernate-mapping auto-import="false">
<subclass entity-name="AbstractCheckActivity_AUD" discriminator-value="AbstractCheckActivity" table="ACTIVITY_AUD" extends="AbstractActivity_AUD">
<join table="ACTIVITY_CHECK_AUD">
<key>
<column name="ACTIVITY_ID" length="255" scale="2" precision="19"/>
<column name="REV"/>
</key>
<property name="durationInMinutes" insert="true" update="false" type="integer">
<column name="DURATION_IN_MINUTES" length="255" scale="2" precision="19"/>
</property>
<properties name="relatedActivity">
<property name="relatedActivity_id" insert="true" update="false" type="integer">
<column name="RELATED_ACTIVITY_ID" length="255" scale="2" precision="19"/>
</property>
</properties>
</join>
</subclass>
</hibernate-mapping>
This is not a valid mapping document, because properties tag is not allowed within join. The resulting schema doesn't contain column RELATED_ACTIVITY_ID -> this property is always null for historic data (as read by AuditReader).
The problem won't occur if I use joined-subclass inheritance strategy for the hierarchy, but it's not desirable 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, 3 months
[Hibernate-JIRA] Created: (HHH-4881) restrict polymorphic query results
by Domenico Loiacono (JIRA)
restrict polymorphic query results
----------------------------------
Key: HHH-4881
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4881
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0-Beta-4
Environment: Hibernate 3.5.0-Beta-4, MySQL 5.1 Glassfish v3
Reporter: Domenico Loiacono
I'm using JPA 2.0, Hibernate 3.5.0-Beta4, MySQL 5.1 on Glassfish v3.
I want to limit the polymorphic query results using JPA 2.0 syntax (TYPE) :
SELECT e FROM Employee e WHERE TYPE(e) IN (FullTime, Executive)
but it seems that Hibernate 3.5.0-Beta4 doesn't support this syntax because in the generated sql query the 'type' keyword remains unmapped and MySQL throws an Exception:
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(type(employee0_.id) in (5))' at line 1
So I tried with Criteria API:
CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
CriteriaQuery<Employee> criteria = criteriaBuilder.createQuery(Employee.class);
Root<Employee> employee= criteria.from(Employee.class);
criteria.where(employee.type().in(FullTime.class,Executive.class));
But I received an Exception:
Caused by: java.lang.IllegalArgumentException: Unexpected call on EntityTypeExpression#render
at org.hibernate.ejb.criteria.expression.PathTypeExpression.render(PathTypeExpression.java:48)
at org.hibernate.ejb.criteria.predicate.InPredicate.render(InPredicate.java:164)
at org.hibernate.ejb.criteria.QueryStructure.render(QueryStructure.java:258)
at org.hibernate.ejb.criteria.CriteriaQueryImpl.render(CriteriaQueryImpl.java:340)
at org.hibernate.ejb.criteria.CriteriaQueryCompiler.compile(CriteriaQueryCompiler.java:150)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:416)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.createQuery(EntityManagerWrapper.java:489)
So I opened the PathTypeExpression class and in the render method I saw :
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
// todo : is it valid for this to get rendered into the query itself?
throw new IllegalArgumentException( "Unexpected call on EntityTypeExpression#render" );
}
Then I switched to use Hibernate custom query syntax (class) :
SELECT e FROM Employee e WHERE (e.class) IN (FullTime, Executive)
Ok this works fine.
But when I add a join with another entity (Department) that has the same TABLE_PER_CLASS inheritance strategy of entity Employee, I have a new problem:
SELECT e FROM Employee e JOIN e.departments d WHERE d.code = 'D1' and (e.class) IN (FullTime, Executive)
GRAVE: Column 'clazz_' in where clause is ambiguous
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute query
--
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, 3 months
[Hibernate-JIRA] Created: (HHH-6737) column names in Constraint is not quoted even column name is quoted in mapping
by Strong Liu (JIRA)
column names in Constraint is not quoted even column name is quoted in mapping
-------------------------------------------------------------------------------
Key: HHH-6737
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6737
Project: Hibernate Core
Issue Type: Bug
Reporter: Strong Liu
Assignee: Strong Liu
Fix For: 4.0.0.next
org.hibernate.test.annotations.beanvalidation.MinMax.java
org.hibernate.test.annotations.beanvalidation.Range.java
MinMax.java
@Max(10)
@Min(2)
@Column(name="`value`")
private Integer value;
generates:
create table MinMax (
id BIGINT not null,
"value" INTEGER check (value<=10 AND value>=2),
primary key (id)
)
and so the value reserved word is not quoted in the constraints
same problem exists in "Range.java"
create table Range (
id BIGINT not null,
"value" INTEGER check (value<=10 AND value>=2),
primary key (id)
)
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 3 months
[Hibernate-JIRA] Created: (HV-515) Performance improvement for MinValidatorForString
by Henri Tremblay (JIRA)
Performance improvement for MinValidatorForString
-------------------------------------------------
Key: HV-515
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-515
Project: Hibernate Validator
Issue Type: Improvement
Components: annotation-processor
Affects Versions: 4.2.0.Final
Reporter: Henri Tremblay
Priority: Minor
For a minor performance improvement, MinValidatorForString minValue can be precalculated to prevent the valueOf like it's done in DecimalMinValidatorForString (even if the JVM will probably eventually optimize it).
{code:java}
public class MinValidatorForString implements ConstraintValidator<Min, String> {
private BigDecimal{color} minValue; // Modified: type in BigDecimal
public void initialize(Min minValue) {
this.minValue = BigDecimal.valueOf(minValue.value(); // Modified: Convert to BigDecimal
}
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
//null values are valid
if ( value == null ) {
return true;
}
try {
return new BigDecimal( ( String ) value ).compareTo( {color:blue}minValue{color} ) != -1; // Modified: Compare the BigDecimal directly
}
catch ( NumberFormatException nfe ) {
return false;
}
}
}
{code}
The same things applies to MaxValidatorForString.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 3 months