October 21, 2024
Chicago 12, Melborne City, USA
java

java mongo driver – how do I save entity to mongo that does not serialize with getters

I use java mongo driver to access mongo. I have this example entity class: public class TestJavaMongoDriverEntityMDO { @BsonProperty("_id") private ObjectId id; @BsonProperty("val") private String val; public TestJavaMongoDriverEntityMDO() { this.val = null; } public TestJavaMongoDriverEntityMDO(String val) { this.val = val; } public String getVal() { if (val == null) { return "someValue"; } return val;

Read More
java

Timer delay fluctuations in Java – how to improve?

I am trying to put together a timer class for a game. Until now, I was just using javax.swing.Timer, but after trying to do some operations that require more exact timing (specifically visual interpolation between two ticks’ states when rendering more frames than there are ticks), I found this class’s limitations and it proved unusable.

Read More
java

Groovy Builder- Unable to construct payload while inserting JSONArray

I was struggling to construct a JSON payload using Groovy Builder . Expected JSON payload { "subscriptions": [ { "subscriptionsId": "1243232", "subscriptionName": "Employee", "subscribedCountries": [ { "id": "901f5e1d-1139-49f1-a91e-6324232151bf", "name": "${countryName}", "countryId": "${countryId}" } ] } ] } In one JSON variable json2 , I am constructing the JSON array using the retrieved values ${countryName} ,${countryId}

Read More
java

Spring Boot + Flyway + Testcontainers(oracle) fails “CREATE USER” ORA-01031: insufficient privileges

I am running spring boot v2.3.5 application with oracleDb (com.oracle.jdbc.ojdbc8 v12.2.0.1) and following testcontainer dependencies: <dependencyManagement> <dependencies> <dependency> <groupId>org.testcontainers</groupId> <artifactId>testcontainers-bom</artifactId> <version>1.20.2</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependency> <groupId>org.testcontainers</groupId> <artifactId>oracle-free</artifactId> <scope>test</scope> </dependency> Here is the testcontainer initialization: public class TestcontainersInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> { static OracleContainer oracleContainer = new OracleContainer("gvenzl/oracle-free:23.5-slim-faststart") .withStartupTimeout(Duration.ofMinutes(3)) .withDatabaseName("test") .withPassword("test") .withPrivilegedMode(true) ; static {

Read More
java

How can I create a CriteriaUpdate query where I select the 'id' column if a method its true which changes another column in its table?

I have a Java 8 project. I have a Server class containing: Long id string name string ipAddress String status Its an entity to a SQL database. I want to run a criteriaUpdate query that updates my table based on the method outcome. If ‘id’ 1 cant be pinged, how do I change the ‘status’

Read More
java

How do you show the interstitial on a Sabre Desktop only app?

In a web based sabre app its possible to call the Interstitial service which will show a loading circle during a long running task. The method to do this is found here: https://developer.sabre.com/sdks/travel-agency/sabre-red-360/help?page=interstitialservice This same screen appears when the desktop version is loading. However I would like to use it in my Desktop Red App

Read More
java

Which approach is more efficient with hibernate

Let's consider a class Transaction @Entity public class Transaction { @ManyToOne(fetch = FetchType.EAGER) private Business business; @Column(name = "business_code") private String businessCode; } which method is more efficient to fetch transactions by business using byBusinessCode which is a column in the table Transaction or using byBusiness so the whole object Business which is a dependency

Read More
java

Overlay a Logo and Details on an Image After Capture

I am trying to achieve a result similar to the photo below. I want to display the file information, address, and logo in the top right corner of the image. I have developed an application that allows users to take a photo and add the file name, address, and a logo to it, but the

Read More
java

Jakarta mail – No provider of jakarta.mail.util.StreamProvider was found

Using following dependency in my project to send email 'jakarta.activation:jakarta.activation-api:2.1.3', 'org.eclipse.angus:angus-mail:2.0.3', I have tested the email generation in local using my gmail account as host email and it works fine. but the application throws exception. Application is java web application and deployed in tomcat. verified the lib folder and I do see the both Jars.

Read More
java

SpringSecurity OAuth2 Session Consistency

I have built an OAuth2 client and OAuth authorization server locally using SpringSecurity. The OAuth2 client is configured with the Goole authorization server and the local authorization server. When authorizing through the local authorization server, the authorization server generates an authorization code and redirects back to the client. It checks whether the authorization request OAuth2AuthorizationRequest

Read More