Skip to content

Tag: sql

JPA Cast BigDecimal as string

I’m using JPA to query a database, but something strange happens. In some cases the cast works and compiles fine, but with a BigDecimal it doesn’t let me use the cast to make a LIKE with a String. Here is a part of the code that works: pesoObjetivo is a data type Double But when I try to perform t…

PostgreSql unable to resolve table user

My problem is that intellij raise an error that unable to resolve table user. Table is created in database it can be seen in database in Intellij but it looks like compiler doesn’t have an access to it. Did someone have similiar problem? enter image description here Answer If you can confirm that the ta…

Change a line to prepared statement

I have this line and I am trying to do this line prepared statement but I am not able to do it. What I did is this : the sql table is this Answer This folwoing code should be encapsuled in a ty catch statment Also i hope you add a password hashing function to your code, every thing else

Checking for overlapping appointments in database not working?

I’m saving appointments to a database and have a method that checks if times are overlapping. I’m calling the method using I don’t receive any errors when saving appointments although they can be for the same exact times. I’m converting a LocalTime to a ZonedDateTime to save in the DB …

JOOQ Forced types to convert a BigInteger to BigDecimal for POSTGRES

for a Table , lets say myTable, I have a column myColumn.. the default JOOQ generation creates myColumn as BigInteger, I want to create it as BigDecimal. This is the converter I am using. How should be the forceType configuration look like in the XML file? Answer The reason why your columns are generated as B…

Select all employees sorted by last name in ascending order

How can I implement SQL query in order to select all employees sorted by last name in ascending order in the following Java class: Answer If there is a separate column for last name then it is very much easy to achieve. If there is only one column i.e. full name , then split the string from the last white