1

I have the following query that works perfectly with ms-SQL but failing with oracle

there is sample query, the original is way complicated but this one reproduces the error

@Query("SELECT new Map((s.name + ' - ' + s.name) as name , s.idStandard as idStandard) FROM Standard s ")

jpa model

public class Standard
{


    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(unique = true, nullable = false)
    private int idStandard;

    @Column(name = "Name")
    @NonNull
    private String name;

    @Column(name = "Description")
    private String description;

    @Column(name = "UpdateUser")
    private String updateUser;


    @Column(name = "UpdateDT")
        private Date updateDt;
}

why oracle thinks this is (s.name + ' - ' + s.name) is a number ?

Happy Coder
  • 1,293
  • 1
  • 19
  • 35

1 Answers1

1

I think the world deserves to know :) using concatenate operator || solves the problem!! concatenate operator allows you to concatenate 2 or more strings together.

see the doc for more info https://www.techonthenet.com/oracle/functions/concat2.php

updating the query runs on ms SQL and oracle

@Query("SELECT new Map((s.name || ' - ' || s.name) as name , s.idStandard as idStandard) FROM Standard s ")
Happy Coder
  • 1,293
  • 1
  • 19
  • 35
  • @Jonathan Johx well, from yesterday .. the original query is very big I had to break it down to find the issue – Happy Coder Oct 17 '19 at 20:59
  • @MariaFinkelstein It's OK, someone will give you thanks for this answer. Thanks for letting us know it, if you have some question related to `Spring Boot`, `JPA` , etc let me know :) I like to know a lot of questions answered and not answered. Kind regards. – Jonathan JOhx Oct 17 '19 at 21:13