Questions tagged [pojo]
POJO is an acronym for Plain Old Java Object. The name is used to emphasize that a given object is an ordinary Java Object, not a special object, and in particular not an Enterprise JavaBean.
1,840
questions
0
votes
0
answers
24
views
MongoDB PojoCodecDriver Error Registering 3rd party Package Class
I have an issue registering POJO classes from 3rd party libraries in my project with MongoDB so that I can use the POJOS.
I'm registering the classes first as follows:
PojoCodecProvider ...
0
votes
0
answers
15
views
Spring RestTemplate returning empty result for JSON response when using custom POJO class
I am getting below JSON response from a REST API end point
{
"data": {
"scores": [
12,
23
]
},
"meta": {
"method": "POST"...
1
vote
1
answer
16
views
JOOQ - is it possible to set, for which tables i want to generate POJO (different than records)?
we are using JOOQ generated Records in our application even for use in presentation layer (i know thats kind of antipattern here, but i cannot refactor everything at once).
What I am trying to reach ...
0
votes
0
answers
21
views
Hibernate how to fetch EAGER @OneToMany with criteria query?
I'm new to Hibernate and I have some problems with my code, I have problem with EAGER fetch with my 4 pojo classes:
- Post POJO:
@Data
@Table(name = "post")
public class Post ...
0
votes
0
answers
19
views
We have bult ENUM with jsonschema2pojo 1.0.2 but the same json is not created now
The folowing json was turned into an enum with version 1.0.2 but not with any version after that.
{
"title": "ApiErrorCode",
"description": "",
"type&...
0
votes
0
answers
29
views
Unable to place order for a product, using the same product Id in Rest Assured
I am trying to do one Rest Assured API E2E flow on an E-commerce web site which includes Logging in, adding a product and then creating an order for that product, however I am unable to execute the ...
0
votes
1
answer
43
views
How to avoid duplicated classes in classes with defined fields and no methods
I have a lot of similar classes to create with defined fields, no need constructors, methods.
Sample classes:
public class Adam {
private String name = "Adam";
private int code = 1;
}
...
0
votes
1
answer
66
views
Java Jackson JSON, how to handle custom keys?
I am having difficulties with handling custom property names, or property names with a value that I am not sure how to handle, in my POJO class.
For example, when I retrieve this JSON body:
{
"...
0
votes
0
answers
64
views
Cannot resolve symbol 'persistence' in import javax.persistence.Entity; import javax.persistence.Id; using gradle [duplicate]
this is my person.java
package com.example.bootdemoapp.entities;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax....
0
votes
0
answers
31
views
How to get examples from schema to POJOS generated via generated Pojo's via jsonschema2pojo-maven-plugin
We have example keyword in our JSON schema like "examples" : [ "001" ]. How do I add this to the generated Pojo's via jsonschema2pojo-maven-plugin. As the plugin is ignoring the ...
0
votes
1
answer
39
views
Changes in POJO are not reflecting in JSON payload in java
I am using POJO to create a JSON message for API input. Some of the fields from the JSON message were in lower case and I changed them to upper case but when I log the payload it the fields are still ...
1
vote
0
answers
25
views
Should input POJOs be assigned to an agent field (variable) and define other fields (variables)?
In Anylogic, I use a POJO class that keeps the input data of an agent. I instantiate a POJO object for an agent and feed it to that agent as a parameter. After I instantiate a POJO object for an agent,...
1
vote
2
answers
43
views
Retrofit onResponse not working but onFailure can be execute
Can anyone help me? I use Log.e("CHART_RESPONSE", "sus" ); to see where it executes, and it shows in OnFailure. I've been trying to solve it for the past three days but it still ...
1
vote
1
answer
95
views
mapping jooq record entity to pojo with nested objects
i have two tables d_cities, d_countries. Mapping between them is unidirectional like this:
also, i have two pojo dtos like this:
Entity classes are jooq generated.
Now I can't come up with the ...
0
votes
0
answers
20
views
How to convert this complex json with same key names of array type to pojo classes
I have this json response schema which i want to convert into the pojo class so that i can iterate the values in items field and assert them
{
"layout": {
"items": [
...
0
votes
0
answers
23
views
Cannot find MongoDB driver PojoCodec when running SpringBoot integration tests
I have a project running on Spring Boot 2.4.0, making use of MongoDB driver 3.12.8.
I have written a set of integration tests making use of this configuration bean:
@Configuration
public class ...
0
votes
0
answers
24
views
How to assign a default value to field on Pojo codec error?
I use the MongoDB java synchronous driver to work with my database, PojoCodecProvider is used to deserialize the PlayerData class, which stores player statistics. If some field of the class has ...
0
votes
0
answers
38
views
Can't get Postman to give a 200 despite following freeCodeCamp tutorial on Springboot
I have followed a beginner guide from freeCodeCamp, and unlike the video, do not get a 200 status code instead a 404. I have searched stack overflow and other forums but nothing works.
postman showing ...
0
votes
0
answers
122
views
pl.pojo.tester.internal.utils.SetterNotFoundException
Trying to upgrade java17/springboot 3.0.6
Using pojo tester version as testImplementation 'com.obsidiandynamics.pojotester:pojotester:0.9.0' .
I assume that 0.9.0 version supports till java 11, is ...
0
votes
1
answer
67
views
What POJO, DTO, Entity and other such components called?
I am searching for a keyword which defines POJO, Entities, Controllers and other components all together?
As I wanted to know about all of them, I was searching for a site, so I tried searching Java ...
0
votes
0
answers
21
views
POJO class without hardcoded value in Android Studio Java
Is it possible to parse JSON response from an API without hardcoding the Object name? I want to parse this JSON but the value of random_number is always changing so I am not able to hardcode it in my ...
0
votes
1
answer
55
views
Convert a POJO to AVRO schema
Given a POJO (e.g. User.java), are there any Maven plug-ins that convert it to an AVRO schema avsc on compilation?
I tried Schema schema = ReflectData.get().getSchema(User.class) but this approach ...
0
votes
2
answers
169
views
NullPointerException Repository in Spring controller class [duplicate]
I'm getting NullPointerException in the bellow code at controller itself. Before going to service class. I couldn't find where I go wrong. As I'm new to spring.
java.lang.NullPointerException: Cannot ...
0
votes
1
answer
35
views
Java POJO instanciate member as soon as it declaration
With my team we are refactoring an app and we're adding lombok to help writing (and reading) pojo class.
There are differents issues with this refactoring and some of you may have hives after reading ...
0
votes
0
answers
12
views
I am getting LinkedHashSet instead of Classes in below attached code snippet
I want to implement POJO that will contain small POJO's inside master POJO. As well all configuration needs to be read from YAML file, while running my spring boot application I am getting always ...
0
votes
1
answer
58
views
How to not include a field in Request object while communicating to an endpoint?
I am having a POJO UserRequest.java which has 4 fields in it and my use case is that I need to send this POJO as request object with 3 fields to REST Endpoint-1 and as another request object with 4 ...
0
votes
0
answers
28
views
Consequences on Flutter unit testing requiring all model objects to extend equatable
When testing for object data equality, models need to override both operator==() & hashCode(), and possibly be immutable if equatable was used.
What would be the consequences in general in term of ...
0
votes
1
answer
185
views
Correctly extend Object class in JavaScript?
I would like to take a record (plain Javascript object) of arrays and embelish it with some additional properties/methods, preferably by creating a new instance of a class:
class Dataframe extends ...
0
votes
0
answers
41
views
How to jsonignore a field based on depth level during deserialization
I have a specific field in a class that I want to ignore if the class depth is more than 2. So if the class is too deeply nested I want to ignore only field of the nested class.
1
vote
0
answers
114
views
How can I convert this piece of JSON to POJO?
I am pulling a JSON file from the Clash Royale web API and trying to fully convert it to a Java object using the Jackson ObjectMapper class. The json file I am pulling describes a Clash Royale player. ...
0
votes
1
answer
53
views
Convert Map to POJO while maintaining original Types in Java
I need to convert a Map<String, Object> into a POJO and maintain all original types of the Map.
Take as example this simple POJO:
@Data
@JsonInclude(Include.NON_NULL)
public class mObj{
...
0
votes
0
answers
24
views
Transfer a Pojo via thymeleaf in springboot
I am trying to write a little springboot app where a User can assign themself to groups which are loaded from the backend.
For accessing the template via @getmapping I add the group entity via
model....
0
votes
3
answers
173
views
How to remove POJO class name from the output string?
I have below POJO
package com.beans.test;
import lombok.Data;
@Data
public class Person {
private int id;
private String name;
private Integer age;
private Boolean isEmployed;
...
0
votes
0
answers
41
views
Mapping JSON to a nested Java POJO
I am having difficulties mapping a JSON to a nested POJO class using Jackson.
JSON:
{
"username" : "name123",
"region" : "EU",
"MandatoryProperty1" : &...
0
votes
0
answers
15
views
Deserializing with Gson into different POJO types [duplicate]
I have Websocket API, which spews out data in JSON format, and client endpoint reacts on them asynchronously.
Since Jsons are lengthy, I want to work with them in deserialized form. Gson can ...
0
votes
0
answers
83
views
Set multiple instances of a POJO when there is more than one object (as part of POJO) with the same value in java
I am facing a scenario where I need to have a POJO class get instantiated for multiple rows in an excel sheet that have the same value for one cell in each row. The current code will only instantiate ...
0
votes
1
answer
83
views
JAXB XML to Pojo using inheritance how to
I receive some XMLs from some endpoints. The basic structure of each response is similar (I get XML, no xsd):
Endpoint Name-Address
<RESPONSE>
<INFO>
<ret_code>0</ret_code>
...
0
votes
1
answer
290
views
Map XML list / XML elements with different attribute values to separate fields
I have an XML file that looks like this:
XML file:
<foobar name="quux">
<supplement key="head">this is a text row</supplement>
<supplement key="...
0
votes
1
answer
63
views
springboot returns different pojos according to different controller
I would like to ask when I have controllerA, I want to display id, emailTitle, emailBody, and when controllerB, I want to display emailBody and correspondingApi. I would like to ask, is it possible to ...
0
votes
0
answers
279
views
Hibernate does not insert a value into the database
I've started learning Hibernate and ran into a problem: when I try to insert a value into my Postgres DB, it just disappears. I can not understand what I do wrong.
Here my POJO I try to upload
@Entity
...
0
votes
1
answer
386
views
Error when trying to convert a POJO Class to Json String with GSON
I am trying to convert a POJO class to Json using Gson, but when I try to do it I get an error and I have no idea the exact solution.
My Java version is 19 and this is my class:
public class ...
0
votes
0
answers
249
views
Converting Oracle Database Types to Postgres / Hibernate Mapping
Currently i am migrating my legacy application from Oracle to Postgres.
Within my POJOs i am having issues with following new datatypes.
Datatype in Oracle
New Datatype in Postgres
Data Type in ...
0
votes
3
answers
253
views
Deserialize Nested Json Record From Postgres To POJO using Jackson
I am preety new to Jackson and how it really works under the hood when its get complicated to an issue of what i am facing. I have a record coming from the database which is stored as JSON TYPE (using ...
0
votes
1
answer
558
views
Why do we need to use POJO class and serialization in RestAssured, when we can directly send request body in the form of String?
What is the realtime use case for serialization in RestAssured?
Even though we can send request body(JSON) as String.
I tried googling but did not get satisfying results.
0
votes
1
answer
117
views
Convert json string response to pojo
I am calling an API using rest template like below:
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, entity, String.class);
And here is the json response string that i ...
-2
votes
1
answer
86
views
Pass a class as argument to another class Java
I am using a data class written in POJO in package myApp. I have another Package UtilLibrary which I have imported as a jar file to the package myApp.
I have developed a method in UtilLibrary by ...
-4
votes
1
answer
44
views
How to Restrict unassigned variable to not get from POJO to JSON? [closed]
I have a class A, with two variable varOne, varTwo,
While assigning I only assigned varTwo, but when converting to JSON I'm getting both the value
one which was unassigned is as null.
What can I do ...
0
votes
1
answer
251
views
How to avoid duplicate POJOs in different web services, Java
I have a webapp with multiple Spring services (they each have their own ear and web-controllers) and they talk to each other via REST calls. Some of the different services use the same data POJOs. The ...
0
votes
0
answers
71
views
class pojo with csv vs protobuf format
I have a classa java class a pojo defnit with csv files that I want to transform into a protobuf format message. Here is the class:
@CsvRecord(separator = "\\|")
public class ServalMvtr2Pojo ...
0
votes
0
answers
23
views
Don't serialize part of POJO if user defined default values exists [duplicate]
I have a POJO:
public class Quux {
private String name = "";
private String foobar = "a-default-value";
public String getName() {
return name;
}
...