[Hibernate-JIRA] Created: (HHH-6636) Properties listed inside "<properties>" tag are not audited
by Andrey Kovalev (JIRA)
Properties listed inside "<properties>" tag are not audited
-----------------------------------------------------------
Key: HHH-6636
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6636
Project: Hibernate Core
Issue Type: Bug
Components: envers
Environment: Hibernate 3.6. Found at MySQL 5
Reporter: Andrey Kovalev
Here is how the bug was found:
I am using envers to audit my ParameterToValue entity. Its properties "containerId", "containerType", "parameterId" which do appear as columns in a mapped DB table "values_for_params" (a regular Hibernate table), are missing at the envers generated "values_for_params_AUD" DB table. I need the ability to get historic "value" for given (containerId, containerType, parameterId).
**The ParameterToValue class:**
@Audited
public class ParameterToValue extends BasicValueHolder {
private Long containerId;
private ContainerType containerType;
private Long parameterId;
public ParameterToValue(ContainerID containerId, Long parameterId, Value value) {
super(value);
this.containerId = containerId.getContainerId();
this.parameterId = parameterId;
containerType = containerId.getContainerType();
}
ParameterToValue() {
}
public Long getParameterId() {
return parameterId;
}
public void setParameterId(Long parameterId) {
this.parameterId = parameterId;
}
public Value getValue() {
return value;
}
public void setValue(Value value) {
this.value = value;
}
public Long getContainerId() {
return containerId;
}
public void setContainerId(Long containerId) {
this.containerId = containerId;
}
public ContainerType getContainerType() {
return containerType;
}
public void setContainerType(ContainerType containerType) {
this.containerType = containerType;
}
}
**The Hibernate mapping definition:**
<class name="platform.server.dataservices.model.ParameterToValue" table="values_for_params">
<cache usage="read-write" include="all" />
<id name="id" column="ID">
<generator class="native"/>
</id>
<properties name="uniqueProps" unique="true">
<property name="containerId" index="ParamValsContainerIdIndx"/>
<property name="parameterId" index="ParamValsParamIdIndx"/>
<property name="containerType" column="CONTAINER_TYPE">
<type name="org.hibernate.type.EnumType">
<param name="enumClass">platform.server.dataservices.model.ContainerType</param>
<param name="type">4</param>
<!-- 12 = string, 5 = smallint, 4 = integer, default 4 -->
</type>
</property>
</properties>
<many-to-one name="value" cascade="all" lazy="false" unique="true" index="PRM_VAL_IDX"/>
</class>
**SHOW CREATE TABLE `values_for_params` in MySQL:**
CREATE TABLE `values_for_params` (
ID` bigint(20) NOT NULL AUTO_INCREMENT,
`containerId` bigint(20) DEFAULT NULL,
`parameterId` bigint(20) DEFAULT NULL,
`CONTAINER_TYPE` int(11) DEFAULT NULL,
`value` bigint(20) DEFAULT NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `value` (`value`),
UNIQUE KEY `containerId` (`containerId`,`parameterId`,`CONTAINER_TYPE`),
KEY `ParamValsParamIdIndx` (`parameterId`),
KEY `ParamValsContainerIdIndx` (`containerId`),
KEY `PRM_VAL_IDX` (`value`),
KEY `FKE02CB4F981565307` (`value`),
CONSTRAINT `FKE02CB4F981565307` FOREIGN KEY (`value`) REFERENCES `value` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8
**SHOW CREATE TABLE `values_for_params_AUD` in MySQL:**
CREATE TABLE `values_for_params_AUD` (
`ID` bigint(20) NOT NULL,
`REV` int(11) NOT NULL,
`REVTYPE` tinyint(4) DEFAULT NULL,
`value` bigint(20) DEFAULT NULL,
PRIMARY KEY (`ID`,`REV`),
KEY `FKE093BE4AEB88DFB` (`REV`),
CONSTRAINT `FKE093BE4AEB88DFB` FOREIGN KEY (`REV`) REFERENCES `DesignRevisionEntity` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 5 months
[Hibernate-JIRA] Created: (HHH-6121) Hibernate statistics should log at DEBUG level instead of INFO
by Philippe Laflamme (JIRA)
Hibernate statistics should log at DEBUG level instead of INFO
--------------------------------------------------------------
Key: HHH-6121
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6121
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.6
Reporter: Philippe Laflamme
With HHH-3659 came lots of output at INFO level during bulk operations:
{noformat}
2011-04-13 14:16:21,538 - INFO - hibernate.stat.Statistics - HQL: null, time: 0ms, rows: 0
2011-04-13 14:16:21,538 - INFO - hibernate.stat.Statistics - HQL: null, time: 0ms, rows: 0
2011-04-13 14:16:21,577 - INFO - hibernate.stat.Statistics - HQL: null, time: 0ms, rows: 0
2011-04-13 14:16:21,577 - INFO - hibernate.stat.Statistics - HQL: null, time: 0ms, rows: 0
2011-04-13 14:16:21,626 - INFO - hibernate.stat.Statistics - HQL: null, time: 0ms, rows: 0
2011-04-13 14:16:21,626 - INFO - hibernate.stat.Statistics - HQL: null, time: 0ms, rows: 0
{noformat}
Hibernate used to be completely silent (except at startup) when set at the INFO level. Now, it is very verbose.
If someone needs query timings they are probably debugging something. This output should probably set at DEBUG level instead of INFO.
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-3440) 3.3.0 GA with MySQL 5.0 throws table validation exception
by Carlo Luib-Finetti (JIRA)
3.3.0 GA with MySQL 5.0 throws table validation exception
---------------------------------------------------------
Key: HHH-3440
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3440
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.3.0.GA
Environment: Hibernate 3.3.0 GA
MySQL 5.0
JBoss 4.2.2
Reporter: Carlo Luib-Finetti
Hibernate immediately throws an exception at application startup, when it does the schema validation.
org.hibernate.HibernateException: Wrong column type in dpjw.assessment for column NOTES. Found: text, expected: longtext
Comparing the sources of 3.2.0 with 3.3.0 I can see that someone set two java statements into comment. The 3.2 version of MySQLDialect.java looks like this:
protected void registerVarcharTypes() {
registerColumnType( Types.VARCHAR, "longtext" );
registerColumnType( Types.VARCHAR, 16777215, "mediumtext" );
registerColumnType( Types.VARCHAR, 65535, "text" );
registerColumnType( Types.VARCHAR, 255, "varchar($l)" );
}
while the new 3.3.0 version is this:
protected void registerVarcharTypes() {
registerColumnType( Types.VARCHAR, "longtext" );
// registerColumnType( Types.VARCHAR, 16777215, "mediumtext" );
// registerColumnType( Types.VARCHAR, 65535, "text" );
registerColumnType( Types.VARCHAR, 255, "varchar($l)" );
}
If I uncomment these (and others in the same Java file!), the validation process is ok.
Is there any reason why these statements (and others!) were commented out???
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-3530) The code in the 3.3.1.GA subversion tag is not the code that's been released on the maven repository.jboss.org as 3.3.1.GA
by Geoffrey De Smet (JIRA)
The code in the 3.3.1.GA subversion tag is not the code that's been released on the maven repository.jboss.org as 3.3.1.GA
--------------------------------------------------------------------------------------------------------------------------
Key: HHH-3530
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3530
Project: Hibernate Core
Issue Type: Bug
Components: build
Affects Versions: 3.3.1
Reporter: Geoffrey De Smet
Here's the proof:
http://fisheye.jboss.org/browse/Hibernate/core/tags/hibernate-3.3.1.GA/co...
contains the lines (44-45):
registerColumnType( Types.CLOB, "longtext" );
registerColumnType( Types.CLOB, 16777215, "mediumtext" );
registerColumnType( Types.CLOB, 65535, "text" );
But the sources jar downloaded from
http://repository.jboss.org/maven2/org/hibernate/hibernate-core/3.3.1.GA/...
file
org\hibernate\dialect\MySQLDialect.java
so on my pc
C:\Documents and Settings\gds\.m2\repository\org\hibernate\hibernate-core\3.3.1.GA\hibernate-core-3.3.1.GA-sources.jar!\org\hibernate\dialect\MySQLDialect.java
has these lines (66-68) instead:
registerColumnType( Types.CLOB, "longtext" );
// registerColumnType( Types.CLOB, 16777215, "mediumtext" );
// registerColumnType( Types.CLOB, 65535, "text" );
It's not just some copyright stuff that been added (giving it different line numbers), some lines are clearly commented out.
Maybe untagged changes happened in other files too?
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-3930) one-to-one causes redundant select query
by Martijn Dashorst (JIRA)
one-to-one causes redundant select query
----------------------------------------
Key: HHH-3930
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3930
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Reporter: Martijn Dashorst
@Entity
public class Address {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToOne(mappedBy = "address")
private Customer customer;
}
@Entity
public class Customer {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private Address address = new Address();
public Long getId() {
return id;
}
public Address getAddress() {
return address;
}
}
This mapping causes 2 instead of the expected 1 query to retrieve a Customer and its Address from the db:
select * from Customer customer0_ left outer join Address address1_ on customer0_.address_id=address1_.id where customer0_.id=?
select * from Customer customer0_ left outer join Address address1_ on customer0_.address_id=address1_.id where customer0_.address_id=?
Changing the mapping to a LAZY fetch type:
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Address address = new Address();
Causes 3 select queries instead of the expected 2 queries to retrieve a Customer (and its Address) from the db:
select * from Customer customer0_ where customer0_.id=?
select * from Address address0_ left outer join Customer customer1_ on address0_.id=customer1_.address_id where address0_.id=?
select * from Customer customer0_ where customer0_.address_id=?
The third select is superfluous because the relationship is already completely known: you already have the customer, so why not just set it on the address entity?
Making the address field in Customer a @ManyToOne doesn't make a difference.
Making the customer field in Address a @OneToMany does remove the extra select, but forces our model to change the relationship from Customer to List<Customer> where we *know* there'll be only 1 element.
Apparently Hibernate can figure out the reverse relationship with a @ManyToOne - @OneToMany without the need for additional queries, can't this be extended to @OneToOne bidirectional relationships as well?
--
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, 5 months
[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
14 years, 5 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
14 years, 5 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
14 years, 5 months