0

I am using hibernate with postgresql. I am curious if is it possible to map for example this entity:

@Entity
@Data
@NoArgsConstructor
class User {
    @Id
    private Long id;
    private String firstName;
    private String lastName;

}

in database I have columns like first_name, last_name. I got error that I introduce wrong names (when I add for example @Column(name = "first_name"); everything is ok. How can I avoid adding @Column neither change database?

Arghya Sadhu
  • 41,002
  • 9
  • 78
  • 107
Shirabu
  • 99
  • 1
  • 4
  • 1
    Does this answer your question? [How to map Hibernate entity fields using camelCase to snake\_case (underscore) database identifiers](https://stackoverflow.com/questions/25681386/how-to-map-hibernate-entity-fields-using-camelcase-to-snake-case-underscore-da) – Arghya Sadhu Aug 05 '20 at 06:21
  • That's weird because this is the default in Spring Data JPA to convert camel to snake case. Did you configure something? – Simon Martinelli Aug 05 '20 at 08:12
  • It was working in that way, after I used DataSourceBasedMultiTenantConnectionProviderImpl with creating own datasources I need to provide @Column – Shirabu Aug 05 '20 at 08:45

0 Answers0