I need statistics about alert tagged by codes. Alerts are visible for users with group based restrictions. In case when some tag code is only in alerts which are invisible for user then 0 should be displayed in statisitics. Tables structure: I’m using Blaze-Persistence and try to make GROUP BY in LEFT JOIN SUBQUERY with COALESCE in root query. Reason
Tag: jpa
SQL code does not work when converted to JPQL code (ORA-00904 error code)
Thank you very much for looking at this post :). I have the following problem: I have a piece of SQL code that runs perfectly on the Oracle database. The problem comes when I try to run as JPQL code. I get the following error in the Eclipse IDE: Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00904: “THIRDTABLE”.”NAME”: invalid identifier. The SQL that works
Correct value of a json data saved using JPA, spring and kotlin Map
I have a jsonb column in a postgres database where I store a bunch of key/value(1 level) into a column mappped to a a Map<String, Any). The values are supposed to be a String but in code I’m accepting anything. All saved values was passed as ByteArray(byte[]) and it’s stored without problems. The stored value is transformed to a String
JpaRepository SQL syntax error when trying to save to MySQL Date
I have the following row in my MySQL Table: https://i.stack.imgur.com/u0FC4.png This column is represented as: And it is bound to a Thymeleaf form like so: Now if I insert a date into the MySQL db directly, the date is loaded and set to the correct date on the form: https://i.stack.imgur.com/e35lr.png But every time I try to save or edit the
Problems with JPA Hibernate Query with ‘Interval’
I need the possibility to retrieve the orders for the past 6 months for my backend application. After some research , I’ve found out that JPA does not support the INTERVAL definition. Is there a workaround for archiving this particularly function ? Answer In that case use the JPA provided functionality , where native sql code is not required. and
What is the best way to update data in database using Native Query
Here if one of data in rule object is null apart from rule_id(As it’s necessary) this query will fail, so instead I can format string for each value in Rule object and concat them excluding which has null value in Rule object but is there any better way to do this? Because if there are 100s of columns then this
How to create LinkedList of JPA entities
I have a scenario where I need to create an entity which has references to list of predecessors and list of successors. when a request is received, I need to create entity like below: Request: My new entity “task2” should now be created as below in DB. While saving task2 with previous as task1 and next as task3, I also
Using BETWEEN in native query in JPQL
I tried to make a query using BETWEEN in JPQL, I already tested it in SQL and it works, but when I implemented in JPQL I got an error: Caused by: javax.persistence.PersistenceException: Exception […
Unable to locate appropriate constructor on class [ClassName]
I want to send a sql query by using Spring JPA like : However, when I remove some fields like “ms.width”, I get the error: I understand that return Object[] cannot be parsed to DTO object. If I write constructor without the parameter – “Width”, it will work properly. However, I want to provide that a query can be sendable
(N + 1) selects problem with child Map-collection
friends! I have these entities: Document: and ChangeNotice: And these are my repositories: For Document: and for ChangeNotice: So, when i want to get Document with changeNotices, thats not a problem, i have only one select. But when i want to get ChangeNotice with documents – i have (n + 1), first for document, and n for changeNotices Map. I