I am using javax.validation for validating request in an API developed using spring. I have to validate List<Integer> so that all values must be a positive number and size of the list must be exactly equal to some fix number e.g. 2. Valid request should be [ 1,2] Invalid request should be [-1,2] or [1,2,3] Answer EDIT: Just realized how
Tag: spring
Synchronous publish for rabbitmq
I want to have two sets API for the clients to publish messages sync send(no retry, fail immediately and send status back to the clients synchronously) async send (publisher and confirm callback, with retry, log and drop the message after certain retries). I am able to implement this by enabling confirm and return. Is there any way to implement Synchronous
Spring Integration file only once from SFTP across several sessions
I have a Spring Integration WorkFlow which downloads files from a SFTP directory. This is done with a RemoteFileInboundChannelAdapterSpec and IntegrationFlows. Spring Integration remembers within a session which files it has already downloaded, can I do this across sessions e.g. through a database and if so how? Answer It is done not within the session, but by some specific FileListFilter
Use batch mode for dynamic listener
I am using a dynamic message listener. An example is shown below. I want to convert this to a batch listener (consume multiple messages at once). Is there a way to convert this, so that the listener consumes a list of consumer records? I am using spring-kafka with spring-boot. Thanks in advance Answer Implement BatchAcknowledgingConsumerAwareMessageListener instead.
Spring repository: HQL using constructor doens’t parse NULL values
I’ve a Spring Repository with this HQL query: PupillaryDistanceDTO is a POJO annotated with @AllArgsConstructor(Lombok); unfortunately those null values I want to pass to the constructor are creating some troubles: Removing those null and replacing with some table’s columns, it works. Is there a way to tell Hibernate to interpret those null in the right way? Answer You could try
How to check UUID null value in JPQL?
I am using JPA/Hibernate. So I wanna to do nullCheck in JPQL, but when I do that it does not determine dataType. JPQL Query: EXCEPTION: Caused by: org.postgresql.util.PSQLException: ERROR: could not determine data type of parameter $1 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2532) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2267) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:312) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369) at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:153) at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:103) at jdk.internal.reflect.GeneratedMethodAccessor582.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114)
Running a Java configured Spring MVC Application fails to load ApplicationContext, raises java.lang.reflect.InaccessibleObjectException
Environment Eclipse IDE for Enterprise Web applications Tomcat 9 Server Code I started learning spring, following a Udemy course (by Chad Darby). In it, a spring mvc app is configured in java. Relevant files are given below: DemoAppConfig.java MySpringMvcDispatcherServletInitializer.java pom.xml Error While running the web app on tomcat 9 server from eclipse, the following exception is raised: Why is it
How to fix data conversion error: jdbcTemplate.update, writing Enum to H2 database
I use PostgreSql for my main code and H2 for testing, and get different results (test fails). My class with an Enum type field SQL schema is My DAO class In my test method: Everything works with PostgreSql, but test with H2 fails with data conversion error: I think “java.sql.Types.OTHER” that I used in PreparedStatement for Gender is converted automatically
Multiple boolean values in if else statement is always false in Java
I am stuck to this method because of the if else condition says that Condition usersInSales && usersInPayments is always false Condition usersInSales && usersInLoans is always false Condition usersInPayments && usersInLoans is always false I tried different condition combinations and added the false values to try resolve it but it didn’t help. Please can I have some help? Thanks
Java 8 – Best way to read and store a file received in REST service
I want to have an application where user can upload a csv file in front-end (Angular). I want a rest service to read it and then store the file as a BLOB into Oracle database. For the REST service, I will receive a MultipartFile object: For the entity, it will be something like this: I saw that I have getInputStream()