Postgresql reserved word problems

Asked

Viewed 289 times

0

Dear friends, I am using locally a code downloaded from Github for educational purposes and I am having trouble deploying War, the error has to do with a reserved word from the database used in the roles table Caused by: org.postgresql.util.Psqlexception: ERROR: syntax error on or next to "Authorization\\"

The Project makes use of JSF, Hibernate ie is a Web project and as it makes use of JPA I directed to the use in the Postgre database originally it is tested in Mysql So my question is does there exist how to resolve this issue without needing to change the bank?

Note: the project belongs to Mr. Arthur Gregorio https://github.com/arthurgregorio/web-budget

I’ll put some class information

a) entity

@Entity
@Table(name = "roles")
@IdentityManaged(Role.class)
public class RoleTypeEntity extends AbstractIdentityTypeEntity {

   @Column(name = "authorization")
   private String authorization;

b) a consultation

final List<Role> roles = queryBuilder.createIdentityQuery(Role.class)
            .where(queryBuilder.equal(Role.AUTHORIZATION, authorization)).getResultList();

c) a class that is not annotated is not an entity

@Named
@Dependent
public class Authorization {
  • Sets the class code as error ...

  • Authorization is a reserved word in postgresql, see which class is using it as a table name and change to another name. probably using the @table("Authorization") annotation, something like that.

  • No, there is no entity class or be annotated with @table as you exemplified, I will edit the question with more information about the system classes.

  • Is the name of the Authorization column in the Roletypeentity class, changes the name of that column to another name to see if it works

  • You can use the delimited identifier or quoted identifier of Postgresql https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS. Use: @Column(name = "\"authorization\"") to embed the quotes to what is sent to Postgresql.

1 answer

0

So my question is does there exist how to resolve this issue without needing to change the bank?

Yes, by changing the code. Modifies the column name where you have the reserved word Authorization:

@Column(name = "auth") // Muda o nome aqui!
private String authorization;

That should solve your problem. I hope I’ve helped ^^

Browser other questions tagged

You are not signed in. Login or sign up in order to post.