Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6553453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:35:01+00:00 2026-05-25T12:35:01+00:00

I am using envers to audit my ParameterToValue entity. Its properties containerId, containerType, parameterId

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:35:01+00:00Added an answer on May 25, 2026 at 12:35 pm

    Fixed. In case anybody needs the answer:

    The problem was that envers ignored whatever was written inside the properties tag. When I removed the tag this way:

    <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>
            </type>
        </property>
    </properties>
    

    Became:

    <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>
      </type>
    </property>
    

    This way, all of the properties became audited, but I still needed the triplet (containerId, parameterId, containerType) to be unique. The final solution was this:

    <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>
      </type>
    </property>
    
    <properties name="uniqueProps" unique="true">
      <property name="containerId" insert="false" update="false"/>
      <property name="parameterId" insert="false" update="false"/>
      <property name="containerType" insert="false" update="false"/>
    </properties>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am already using Hibernate Envers to audit entities that are updated by a
I'm using Envers to audit different fields of my entities. The framework works in
I have not been using envers for very long, and i have hit a
I'm using Hibernate envers to track all changes made to my database objects. These
I'm using jQuery on this site, which has form inputs. I'd like one particular
To add an audit trail to our application we decided to use NHibernate.Envers. To
I'm using Hibernate Envers for auditing. It works fine. However, I'm try to get
We are using Hibernate Envers and have the following situation: A class BusinessObjectType and
Using the standard input, the user enters 1 letter. If its a valid lower-case
I'm using jQuery ColorBox to display a shopping cart item. When a user enters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.