how to properly handle case when theres no records in the db table?
hey guys. so i have my CustomerRepo in my service and i want to handle a scenario when there are no customers with given id. so far i have this:
```java
Optional<Customer> customer=customerRepository.findById(Long.valueOf(paymentInformationRequest.getClientId()));
if (customer.isEmpty()) {
log.info("BGWService.createPaymentInformation. no customer with id: {}", paymentInformationRequest.getClientId());...
Spring JPA
I am tryna Delete the forgotPassword Enetity if the Otp expired time is passed out and that is 10 sec right now but after the Otp time expired the otp entity is not deleting itself from Db . Here is the implemet ```if (forgotPassword.getOtpExpireDate().before(Date.from(Instant.now()))) {
if (forgotPassword.getOtpExpireDate().before(Date.from(Instant.now()))) {
Long fId = forgotPassword.getForgotpasswordId();...
if (forgotPassword.getOtpExpireDate().before(Date.from(Instant.now()))) {
Long fId = forgotPassword.getForgotpasswordId();...
Why I get this error?
I was copying exactly the same code from a video I was watching about graphics.
It worked perfectly for him but not for me, why?...
Java Mail Sender
I am Getting issue while try to send a email to the user after config everything and i dont know how to resolve it ```Failed messages: org.eclipse.angus.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com , 587; timeout -1;
nested exception is:
java.net.UnknownHostException: smtp.gmail.com ; message exceptions (1) are:
Failed message 1: org.eclipse.angus.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com , 587; timeout -1;
nested exception is:...
return only http status from the controller
hey guys. i want to ask for some help. i have a controller and i want it to return only http status and no body. can i do it this way?
```java
@PostMapping(value = "/createPaymentConfirmation", produces = "application/json")
public ResponseEntity createPaymentConfirmation(@RequestBody @Valid PaymentDTO paymentConfirmationRequest) {
paymentService.createPaymentpaymentConfirmation(paymentConfirmationRequest);...
How to add blank lines to the end of a Document?
I'm working on a text editor and it needs to copy some text from one JTextArea to another at the same line, but when one adds a line I can't copy it over with the code I'm using because the document doesnt have enough Elements. My code is ```java
addCaretListener(new CaretListener() {
public void caretUpdate(CaretEvent ce) {
JTextComponent comp = (JTextComponent)ce.getSource();
int pos = comp.getCaretPosition();...
How to connect Java server to node.js?
in simple terms, I am trying to host a website that you upload a .mp4 to, which i want it to be sent to a java server, where the java server then returns a different video. how can i accomplish this?
I.E. what build tools and software, and what dependencies help me work with servers...
Custom AuthenticationFailureHandler
i am tryna make a Custom Authentication Failure Handler like this ->
```
@Component
public class CustomAuthenticationHandler implements AuthenticationFailureHandler {...
column "client_id" of relation "payments" does not exist
hey guys. can smb help me out? in my java project i have this entity:
```java
@Data
@Entity
@Table(name="payments")...
help with custom validator
hey guys. can smb help me out with writing my won validation annotation? i have entity
Payment
and DTO PaymentDTO
and they have private BigDecimal amount
field. i want to validate it bc i want this field's length to be 7 positions at maximum. so far i have this:
```java
@Documented
@Constraint(validatedBy = AmountValidator.class)
@Target( { ElementType.METHOD, ElementType.FIELD })...Text color not changing
I have a custom class that extends JTextArea, I'm eventually going to use it to copy information between two different views but figured I might as well implement a quick dark mode. The problem is my new AttributeSet isn't applied, and I can't tell why. I've used StyledDocument.insertString() before for setting text and background color(working with a JTextPane then), but here it doesnt seem to work the same way. Do I need to extend a different class?
generate DB record id in the DB and not in java
hey guys. i have pojo that is being inserted into my DB. i dont want to have
id
field in my pojo and let my DB generate record id. can i do it somehow? thanksRuntime not runtiming
The build just completes after 2-3 seconds. My executable is in the same folder as my main class file
Is there any way to fix this Binary Search Algorithm?
I am trying to make a binary search but it has problems
Not sure what even is the problem
I have a couple classes for registries in my project I'm working on, but I can't figure out how to implement it how I want. Relevant files and error attached. (Registry is in kotlin, but I dont think thats relevant, if it is I can change it over. RegistryObject also was originally but I swapped it back to java for easier debugging, I still dont really know kotlin)
Oauth Authorization
Can anyone suggests how can I learn about Oauth2 theory and implementation ? I am really confused about it that what to learn and what not !