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.

POJO (Plain Old Java Object) is mainly used to denote a Java object which does not follow any of the major Java object models, conventions, or frameworks such as EJB.

The term continues the pattern of older terms for technologies that do not use fancy new features, such as POTS (Plain Old Telephone Service) in telephony, PODS (Plain Old Data Structures) that are defined in C++ but use only C language features, and POD (Plain Old Documentation) in Perl. The equivalent to POJO on the .NET framework is Plain Old CLR Object (POCO). For PHP, it is Plain Old PHP Object (POPO).

1840 questions
20
votes
5 answers

Set object fields from HashMap

Is there a library that can do the following?: Given an Object and a HashMap, it enumerates the keys of the Hashmap and looks up the setters for these keys in the Object and sets the associated values. Something looking like that: public Object…
forker
  • 2,609
  • 4
  • 23
  • 24
20
votes
4 answers

Lombok builder pattern with jackson JsonProperty

I have constructed a Java Object using lombok with builder pattern. But, I am getting the following exception when trying to deserialize a Java object using Jackson. This occurs for fields which has @JsonProperty annotation. Exception in thread…
suraj1291993
  • 474
  • 1
  • 5
  • 15
20
votes
4 answers

How to create pojo classes from XSD?

I am using Spring maven plugin, I want to create POJO classes from specified xml schema in particular folder. I tried with xjc command through java code, but its not generating that classes. secondly, I tried with jaxb, but its dealing with xml file…
Chaitanya Ghumare
  • 351
  • 2
  • 6
  • 18
20
votes
3 answers

Difference among Model, javabean and POJO

I started learning MVC with spring. I have heard lot of time Bean, that contains setter and getter. Model is basically what data flows around, and Pojo which is same as Bean. But I am really confused in all this term and all this look same to me can…
Varun
  • 4,342
  • 19
  • 84
  • 119
18
votes
4 answers

Should Java POJO have field validation and throw exceptions in setter methods?

Let's say we have tens of java POJOs which represent my domain, that is, my data in the system which flows as objects between different layers of my system. The system may be a web application, or a simple desktop application. What the domain…
Gogi
  • 1,695
  • 4
  • 23
  • 36
17
votes
1 answer

How to deserialize XML with annotations using FasterXML

I have the following XML schema: Intermediate A Intro to A Advanced B I need to…
sbenderli
  • 3,654
  • 9
  • 35
  • 48
16
votes
5 answers

Creating immutable objects using JAXB

I am using JAXB to create Java objects from XSD file. I am creating immutable wrappers to conceal objects generated by JAXB (earlier I was updating JAXB objects to implement immutable interface and return interface to client. But realised it is bad…
niteen22
  • 351
  • 3
  • 13
15
votes
3 answers

Android Room: Efficient way to transform json result into db object

Problem I have a POJO parsed from an API call which looks like this public class Article { public Long id; @Expose @SerializedName("section") public String section; @Expose @SerializedName("title") public String title; @Expose …
Kevin.Lam
  • 289
  • 1
  • 4
  • 16
15
votes
2 answers

Parse Json with Gson without POJO?

Hoping there is an easy solution from someone on here. I know there are similar questions but I can't seem to modify them to work with my problem. I am trying to parse the string for "formatted_address" in this json response: { "results" :…
Tevor
  • 316
  • 2
  • 4
  • 15
15
votes
4 answers

Parse XML TO JAVA POJO in efficient way

How to parse and create java pojo for below xml in an efficient way? Kindly suggest any efficient parser. XML format is
DroidEngineer
  • 467
  • 2
  • 9
  • 20
15
votes
7 answers

What is the correct syntax for "is" variable getter/setters in a POJO class?

If a class contains a variable named "blah", then the standard getter/setter syntax is obviously getBlah() and setBlah(). But if I have a POJO class with a variable named isBlah, would I use: public type getIsBlah() { return isBlah; } public…
Nik Reiman
  • 39,067
  • 29
  • 104
  • 160
13
votes
3 answers

What is POJO & DOJO in JAVA?

I have many doubts in POJO. And seek for a clear definition with a tiny example.
JDGuide
  • 6,239
  • 12
  • 46
  • 64
12
votes
2 answers

Ehcache automatic key generation and @Cacheable spring annotation

Does anybody know how the default key generation for Ehcache works? If I have the following method: @Cacheable(cacheName = CACHE_KEY) // CACHE_KEY is static final field. public List list( int firstRecord, int maxRecords, int…
Ivaylo Slavov
  • 8,839
  • 12
  • 65
  • 108
12
votes
2 answers

Convert results of SQLite Cursor to my object

I've executed some queries on my SQLite DB on Android. Main instruction used is this: Cursor cursor = myDB.rawQuery(select, null); Now I want the results of this query to be converted to a generic class I've created in the project. If you think I…
Alex
  • 1,237
  • 3
  • 18
  • 29
12
votes
3 answers

Cannot construct instance of `com.domain.User` (no Creators, like default constructor, exist): cannot deserialize from Object value

I have a controller that accepts ObjectNode as @RequestBody. That ObjectNode represents json with some user data { "given_name":"ana", "family_name": "fabry", "email": "fabry@gmail.com", "password": "mypass", "gender":…
user9347049
  • 1,927
  • 3
  • 27
  • 66