简体   繁体   中英

Auditing with Envers and Hibernate Spatial 4

I'm attempting to use Envers to set up Auditing on my Hibernate entities. However, I'm getting the error:

Could not determine type for: geometry, at table: Location_AUD, for columns: [org.hibernate.mapping.Column(geom)]

Hibernate is happy with the geometry type I'm using without the auditing, but Envers seems to be having trouble with it.

Does anyone know if Envers works with Hibernate Spatial 4? If it does, perhaps someone can spot the issue with my code.

@Audited
@Entity
public class Location {
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_LOCATION")
    @SequenceGenerator(name = "SEQ_LOCATION", sequenceName = "SEQ_LOCATION", allocationSize = 1)
    Long id;

    @Type(type = "org.hibernate.spatial.GeometryType")
    Geometry geom;

    ...
}

I'm using Hibernate 4.2.5 with HibernateSpatial 4.0.0 M1

I was having this exact same problem. Manually adding a Hibernate @TypeDef annotation for the geometry type seems to have worked for me. For whatever reason envers does not automatically pick up the GeometryType mapping even though Hibernate core does. So for our application, I have:

@Entity
@Audited
@Table(name = "geo_element")
@ForeignKey(name = "FK_geo_element__id__element")
@TypeDef(name = "geometry", typeClass = GeometryType.class)
public class GeoElement extends Element {

  @Type(type = "geometry")
  @Column(name = "data")
  private Point data;

  //...
}

We are using Hibernate 4.1 with Hibernate Spatial 4.0-M1 running on top of Spring 3.1.3 and configured using Spring's LocalSessionFactoryBean.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM