the goat
the goat
JCHJava Community | Help. Code. Learn.
Created by the goat on 6/4/2024 in #java-help
ZonedDateTime parse issue
When I pass this to my endpoint:
{
"product": "gas",
"date": "2024-03-11T10:00:00+03:00",
"value": 1738
}
{
"product": "gas",
"date": "2024-03-11T10:00:00+03:00",
"value": 1738
}
for this entity:
@Entity
@Table(name="reading")
public class Reading {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String product;

@ManyToOne
private User user;

@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX")
private ZonedDateTime date;

private BigDecimal value;
@Entity
@Table(name="reading")
public class Reading {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String product;

@ManyToOne
private User user;

@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX")
private ZonedDateTime date;

private BigDecimal value;
in my database as a result I get: 2024-03-11 09:00:00.000 for date. It should be 2024-03-11 09:00:00+03:00 - isn't this covered by @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX")
23 replies
JCHJava Community | Help. Code. Learn.
Created by the goat on 5/28/2024 in #java-help
Detail: Key columns "document_number" and "document_number" are of incompatible types: character var
I've created class Invoice and class Invoice line that is a part of the invoice. Id in Invoice looks like this:
@Id
@Column(name = "documentNumber", length = 14)
private String documentNumber;
@Id
@Column(name = "documentNumber", length = 14)
private String documentNumber;
and the invoice line relationship looks like this:
@OneToMany(mappedBy = "invoice", cascade = CascadeType.ALL, orphanRemoval = true)
private List<InvoiceLine> invoiceLineList;
@OneToMany(mappedBy = "invoice", cascade = CascadeType.ALL, orphanRemoval = true)
private List<InvoiceLine> invoiceLineList;
For Invoice line I have this:
@ManyToOne
@JoinColumn(name = "documentNumber", referencedColumnName = "documentNumber", nullable = false)
private Invoice invoice;
@ManyToOne
@JoinColumn(name = "documentNumber", referencedColumnName = "documentNumber", nullable = false)
private Invoice invoice;
In my code they are both varchar, could the error be caused by PostgreSQL?
4 replies
JCHJava Community | Help. Code. Learn.
Created by the goat on 4/24/2024 in #java-help
consume external API
would like to create a scheduling application for tennis court. I have found an API (https://www.weatherapi.com/) and I have successfully implemented a method to consume the data and insert it into a JSONObject (org.json dependency). I would like to continue further and get stuff as weather km/h, temperature and so on. Do I have to create new classes for every element of the json I am getting or is there a more efficient way to read the data. I will further use that data to create a schedule that follows certain rules. the json looks like this: https://pastebin.com/APRb5953
7 replies