Skip to content

JDBC data types from org.postgresql.geometric are treated as referenced agreggates instead of jdbc data types #1065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iarobles opened this issue Oct 3, 2021 · 1 comment
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement

Comments

@iarobles
Copy link

iarobles commented Oct 3, 2021

There seems to be a problem when save or findById methods of the CrudRepository are called on an entity that has a property of the type in org.postgresql.geometric (for example PGpoint). This types are used to map postgres geometric data types: https://www.postgresql.org/docs/9.4/datatype-geometric.html. A similar problem happens with any of the PostGIS JDBC types.

The error seems to be due to Spring Data JDBC treating the property as if it were a referenced aggregate instead of a data type describing a column data type. For example, for an entity with the following properties:

@Table("example")
public class Example {
    @Id
    private int id;
    private String info;
    private PGpoint singlePoint;

    public int getId() {return id;}
    public void setId(int id) {this.id = id;}
    public String getInfo() {return info;}
    public void setInfo(String info) {this.info = info;}
    public PGpoint getSinglePoint() { return singlePoint;}
    public void setSinglePoint(PGpoint singlePoint) {this.singlePoint = singlePoint;}
}

when save is called on an instance of this class, the following error happens (debug level):

INSERT INTO "p_gpoint" ("example", "is_null", "type", "value", "x", "y") VALUES (?, ?, ?, ?, ?, ?)] for task [PreparedStatementCallback

Note that "x", "y", "isNull", etc. are public properties of the PGPoint class: https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/geometric/PGpoint.java

Let me know if you need more information and thanks in advance!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 3, 2021
@mp911de
Copy link
Member

mp911de commented Oct 4, 2021

Any complex objects are considered to represent references. With version 2.3 we introduced JdbcPostgresDialect that allows registration of simple types that are not converted. We have a similar arrangement in R2DBC.

@mp911de mp911de added status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 4, 2021
schauder added a commit that referenced this issue Nov 15, 2021
schauder added a commit that referenced this issue Nov 17, 2021
Removing final on local variable.

See #1065
schauder added a commit that referenced this issue Dec 7, 2021
Removing final on local variable.

See #1065
Original pull request #1085
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants