Issue Type: Bug Bug
Affects Versions: 3.5.4
Assignee: Unassigned
Components: envers
Created: 17/Aug/12 4:34 PM
Description:

I have a Uni directional one -to-many relationship defined in a class and trying to audit the collection and the join key column in the audit table is inserting with null values, Could anyone help me how to do this?

The example is given below. A Search class which contains a set of SearchParameters. Both of these classes are mapped to tables search and search_param. the class stucture and table structure is given below.

@Entity
@BatchSize(size = 1000)
@Table(schema = "Search")
@Audited
@AuditTable(schema = "Customer" value = "Search_audit")
@Cache(region = "Search", usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Search{

private Long id;
private String description;
private String isSticky;
private Set<SearchParameter> searchParams;

/**

  • @return the deletedFlag
    */

public Search() {
}

public void setDescription(String description) { this.description = description; }

@Column(name = "DESCRIPTION")
public String getDescription() { return description; }

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() { return id; }

@Column(name = "IS_STICKY")
public String getIsSticky() { return isSticky; }



public void setId(Long id) { this.id = id; }

public void setIsSticky(String isSticky) { this.isSticky = isSticky; }



@MapKeyJoinColumn(name="SEARCH_ID")
@Fetch(FetchMode.SUBSELECT)
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "SEARCH_ID")
@Cache(region = "Search.searchParams", usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public Set<SearchParameter> getSearchParams() { return searchParams; }

public void setSearchParams(Set<SearchParameter> parameters) { this.searchParams = parameters; }

}



@Entity
@BatchSize(size = 1000)
@Table(name = "Search_Param")
@Audited
@AuditTable(schema = "Customer" value = "Search_param_audit")
@Cache(region = "SearchParameter", usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class SearchParameter extends AbstractDomainObject {

private Long id;

private String name;

private Set<SearchParameterValue> searchValues;

/*
* @return the id
*/
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() { return id; } }

/**

  • @param id
  • the id to set
    */

public void setId(Long id) { this.id = id; }

/**

  • @return the name
    */
    @Column(name = "NAME")
    public String getName() { return name; }

/**

  • @param name
  • the name to set
    */
    public void setName(String name) { this.name = name; }

/**

  • @param searchValues
  • the searchValues to set
    */

public void setSearchValues(Set<SearchParameterValue> searchValues) { this.searchValues = searchValues; }

@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
@Fetch(FetchMode.SUBSELECT)
@OneToMany(orphanRemoval = true, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "PARAMETER_ID")
@Cache(region = "SearchParameter.searchValues", usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public Set<SearchParameterValue> getSearchValues() { return searchValues; }

}

The search_id in the search_param_audit table always stored as null while auditing the data.

What I should do to fix this?

Environment: Win
Project: Hibernate ORM
Priority: Critical Critical
Reporter: Anna Anil
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira