Open marcodelpercio opened 4 years ago
Can we disable the additional double quotes around every column name please?
This company (SmartNews) doesn't use PostgreSQL at all. So, I'm afraid that they won't make efforts to add the option for you (at least in the short term).
Also, I don't have the bandwidth to work on the feature for you. That said, as the original creator, I'm happy to review your pull requests if you're interested in contributing to this project.
If you're in a hurry, modifying this template file in your fork should work.
In my case, I created a special Gradle task:
task generateEntities() {
dependsOn 'entityGen'
doLast {
ant.replace(token: "\\\"", value: '') {
fileset(dir: 'src/main/java/app/entities')
}
}
}
Hi,
I decided to try this plugin to generate entities from an existing table in PostgreSQL. The table name is apilog
CREATE TABLE public.apilog ( id bigserial NOT NULL, userid int4 NOT NULL, uri varchar(50) NOT NULL, "method" varchar(10) NOT NULL, calltimestamp timestamp NOT NULL, CONSTRAINT api_log_pk PRIMARY KEY (id) );
Because the primary key id is a serial type, there's a sequence automatically generated by PostgreSQL named "apilog_id_seq". Everything works fine in PostgreSQL and I can insert records without specifying an id to have it automatically generated by the sequence (as expected). However the problem comes because of the JPA Entity generated by this plugin. In fact the entity generated is like this.`@Data @Entity(name = "org.oneocean.entities.Apilog") @Table(name = "apilog") public class Apilog {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "\"id\"", nullable = false) private Long id; ... ... `
You see those additional double quotes in the column name? They actually break the JPA entity and whenever I try to persist (or merge) a new entity PostgreSQL raises the following error:
2020-07-01 12:35:41,214 ERROR [org.hib.eng.jdb.spi.SqlExceptionHelper] (executor-thread-2) ERROR: relation "apilog_"id"_seq" does not exist
For some reason the name of the column "id" ends up in the sequence name with the additional double quotes and obviously such sequence doesn't exist. So the result is that I cannot merge/persist any of the entities generated with this plugin. I understand that the purpose of having the additional double quotes is to escape column names but if the side-effect is that the entity is broken it's just not worth having it. Can we disable the additional double quotes around every column name please?
Many thanks