Skip to content

Hibernate @Enity annotation changes Jackson serialization behavior #2267

Closed
@efenderbosch

Description

@efenderbosch

When an object is annotated with @entity, then Jackson doesn't serialize the id.

@Entity
public class Test implements Serializable {
    @Id
    private Long id;
    private String attribute;
    // getters, setters, toString, hashCode, equals, serialVersionUID, etc.
}

This will serialize to

{
  "attribute" : "attribute"
}

Commenting out @Entity will fix the serialization:

{
  "id" : 1,
  "attribute" : "attribute"
}

I've created a minimal project to demonstrate the problem here:
https://github.com/efenderbosch/spring-hibernate-jackson-error

Should I also submit this to the Hibernate project?

I'm using OpenJDK 1.7.0_65 on Ubuntu 14.04.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions