JPA column conversion...

7 views
Skip to first unread message

Bradlee Johnson

unread,
Mar 5, 2019, 2:37:10 PM3/5/19
to Dozer Mapper
I'm working with some legacy database code and have some pojos with field names that match column names in the database.

When I generate JPA entities I get the @Column annotation which has the column name which would match the old legacy field names. An example might be:

    private Integer member_id;
    private String member_name;

The generated artifact for the table might look like this:
   
   @Column(name = "member_id", nullable = false)
   private Integer memberId;
   @Column(name = "member_name", nullable = false)
   private String memberName;

I could map that in XML or I could add annotations for mapping to one of the classes but this seems like a case where a custom converter would be the ticket. Are there any examples or pointers int he right direction?

Thanks
Brad

Bradlee Johnson

unread,
Mar 5, 2019, 5:35:25 PM3/5/19
to Dozer Mapper
Incidentally, I was thinking that whatever plugin is used for the standard annotation mapping might be a springboard for this.

Instead of looking for something like this:

    @Mapping("binaryData")
    private String data;


The plugin/converter would look for this sort of thing and by that it would understand the bi-directional mapping between the legacy class with column name fields and the JPA generated class field name.

@Column(name = "member_id", nullable = false)
 private Integer memberId;
Reply all
Reply to author
Forward
0 new messages