Coder Social home page Coder Social logo

Comments (5)

quaff avatar quaff commented on May 28, 2024 1

Returns the 1-based position of an element in the array. Returns 0 if the element is not found and null if the array is null.

You should use cb.ge(position, 1) instead of cb.isNotNull(position).

BTW, It's handled by Hibernate not Spring Data JPA.

from spring-data-jpa.

quaff avatar quaff commented on May 28, 2024 1

https://docs.jboss.org/hibernate/orm/6.4/userguide/html_single/Hibernate_User_Guide.html#hql-array-position-functions

The function array_position is hql function provided by Hibernate, It will overlay native sql function.

from spring-data-jpa.

quaff avatar quaff commented on May 28, 2024 1

Then it might be another Hibernate bug because it worked before when using user types to map to SQL arrays. In that case array_position was called directly with no adaption needed to provide the documented behavior.

I guess that works before array_position added, it's introduced since 6.4.0, see https://hibernate.atlassian.net/issues/HHH-17335

from spring-data-jpa.

markusheiden avatar markusheiden commented on May 28, 2024

Sorry for misjudging this.

Your suggested change works. Thanks for that. So this issue might be closed.

I used cb.gt(position, 0) though.

But for PostgreSQL, the documentation says: Returns the subscript of the first occurrence of the second argument in the array, or NULL if it's not present. So the NOT NULL comparison worked for us before. Now we need to switch from user types to the "native" array support of Hibernate due to a Hibernate bug. The native array support generates different SQL for this use case.

from spring-data-jpa.

markusheiden avatar markusheiden commented on May 28, 2024

Thanks for pointing me to the docs. Before I thought, these function calls were calls of native functions of the database.

Then it might be another Hibernate bug because it worked before when using user types to map to SQL arrays. In that case array_position was called directly with no adaption needed to provide the documented behavior.

from spring-data-jpa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.