Hibernate - Annotations to apply operation on entity field?

Viewed 18

I have the following JAVA entity

@Table(name = "some_table", schema = "some_schema")
public class SomeEntity{

    @Id
    @Generated(value = GenerationTime.INSERT)
    @Column(name = "id", unique = true)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Size(min = 0, max = 255)
    @Column(name = "node", nullable = false, length = 20)
    private String node;

}

the node property is a HierarchicalId type. When I create a new SomeEntity instance, with a node value '/1/1/', it works fine. However, I'd like to annotate the node field so that everytime a SELECT query is made, it will select the node.ToString() (to get the readable string representation of the node property) instead of SELECT node.

The SELECT node returns X instead of '/1/' and I would like to get '/1/' instead of X. How can I do that ? Is that possible to achieve that without using native query ? Thanks for your help.

0 Answers
Related