Skip to content
Advertisement

Tag: java

%Like% Query in spring JpaRepository

I would like to write a like query in JpaRepository but it is not returning anything : LIKE ‘%place%’-its not working. LIKE ‘place’ works perfectly. Here is my code : Answer The spring data JPA query needs the “%” chars as well as a space char following like in your query, as in @Query(“Select c from Registration c where c.place

Spring Security 3 – always return error 302

I use Spring 4 to create a simple application. Recently, I’m adding Spring Security 3 to the project but always get the Error Code 302 ( so it redirect to home page always ). Here is my SecurityConfig: I have a Controller called AccountController: My WEB-INF structure: The flow is like: User access the web site with http://mylocal:8080/moon => it

Source code has comments after decompile whith JD-GUI

I have converted class files into source code by JD GUI Tool. I open the jar file using JD-GUI version 0.3.5, then open File folder and click “Save All Sources”. There are comments in source code, e.g.: How can I remove those comments? Answer Change the setting under Help > Preferences and uncheck Display line numbers as in image;

Postgres – Column out of range in PreparedStatement – java

got a problem with a preparedstatement using Java 1.7.0.67 on Windows 8.1… Basically I get an error as follows (from the test): I can see it’s telling me I have no ? but they are there for all to see in the before setString message. Can anyone see what is wrong with what I’m doing – I’m new to PreparedStatements

Can’t instantiate class using Hibernate createQuery

I’m trying to use hibernate to create objects, which are not domain models, but I get a incomprehensible error message. My Java code: The class: Stacktrace: The schema for the table: Versions: Frankly, i’m clueless about why it cannot instantiate this class. Answer You get a NullPointerException in the constructor, so the time argument that your query retrieves from the

Spring Boot + JPA : Column name annotation ignored

I have a Spring Boot application with dependency spring-boot-starter-data-jpa. My entity class has a column annotation with a column name. For example: SQL generated by this created test_name as the columns name. After looking for a solution I have found that spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy solved the problem (column name is taken from column annotation). Still, my question is why without naming_strategy set

How to return a string which matches the regex in Java

Here is a method which returns true/ false for each match. Instead I want to get the matched string if it matches. If it doesn’t matches then don’t return. I can have an If condition to check if its true or false. But my specific question here is, how to return the string if it matches? Answer How to get

How to isolate an instance of a class with SuperCsv?

Actually I have a class ArticleModele where I store the content of the columns of the .csv, but I don’t know how to access to a particular instance of the class which corresponds to a particular row in the .csv. Here is my code: And here is the class: Answer The code returns with last result, as it overwrites articleModele.

How to send enclose data in DELETE request in Jersey client?

I have the following server-side code in Jersey 2.x: On client side, I want to use Jersey 2.x client to send a delete request to the above web service. However, from the documentation of Jersey client API, I didn’t find how to enclose the following data in DELETE request: From the Jersey client API, the SyncInvoker class doesn’t support a

Advertisement