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
12
votes
3 answers

Freemarker print date in template

I am trying to print the current date when the template is activated. I have read that I have to pass a new Date() Java object to the template, but I don't know how to do that or where to put it in the code. Does someone know how to pass a Java…
user763222
  • 121
  • 1
  • 1
  • 4
12
votes
5 answers

Saving JSON object to Firebase in Android

I am new to firebase, and I am trying to put JSON object data into my Firebase. I know how to put data as a class object into Firebase, but I want to put JSON object data. Is there any way to put JSON object data into Firebase without converting it…
inin
  • 372
  • 1
  • 4
  • 17
11
votes
1 answer

Custom Class for JasperReports field

I would like to create a report with a custom class as follows: public class Class1 { String cl1_f1; String cl1_f2; } public class Class2 { String cl2_f1; String cl2_f2; Class1 cl1_ob1; } Now I pass Class2 in the report through fields…
jagbandhuster
  • 677
  • 2
  • 7
  • 20
11
votes
5 answers

onActivityResult outside of an activity scope

I'm trying to create an android project that contains shared code which will be used by others. In this project I only have POJO and no android specific classes. Some of the functionality requires calling some activities and is depended on the…
Nitzan Tomer
  • 155,636
  • 47
  • 315
  • 299
11
votes
6 answers

Convert a POJO to a map

Possible Duplicate: How to convert a Java object (bean) to key-value pairs (and vice versa)? What is the best way to convert a List to a List>. Is there a custom method/ API? K = field name of the POJO and V is the corresponding…
Victor
  • 16,609
  • 71
  • 229
  • 409
11
votes
2 answers

error: Entities and Pojos must have a usable public constructor - Java

Whenever I try to compile the app I get this error error: Entities and Pojos must have a usable public constructor. You can have an empty constructor or a constructor whose parameters match the fields (by name and type). -…
ahmed galal
  • 504
  • 5
  • 15
11
votes
2 answers

Android DiffUtil.ItemCallback areContentsTheSame with different IDs

I'm using a RecyclerView to display a list of items that are retrieved from a database as Java objects. One of the fields in the object is the ID of the item in the database, so that further operations can be performed with it. My areContentsTheSame…
micheal65536
  • 558
  • 3
  • 6
  • 26
11
votes
3 answers

android jackson json object mapper array deserialization

i need help parsing a response with the jackson mapper to a POJO. i have this as a response: "data": [{ "item": { "downloaded": false, "moderated": false, "add": false } }, { …
DArkO
  • 15,880
  • 12
  • 60
  • 88
11
votes
3 answers

Jackson custom filter with full POJO data bind

This question extends this question. While the previous solution works great if you only have a couple of fields, it becomes unmaintainable when you have more than a dozen of fields. Right now, my current set up uses full data binding, so I have a…
THIS USER NEEDS HELP
  • 3,136
  • 4
  • 30
  • 55
11
votes
5 answers

Complex Java object to CSV

I'm trying to generate a CSV file from a rather complex Java object. The object is a Session with some attributes and a list of Strings and Messages who in turn have some attributes and a list of Comments that have some attributes. The session class…
Niels Masdorp
  • 2,534
  • 2
  • 18
  • 31
11
votes
5 answers

What's the best way to convert pojo to JSON in Spring

I have a requirement to convert a POJO to JSON string in a Spring project. I know Spring MVC provide a convenient way to return json in the controller by annotate @ResponseBody, I wonder how does Spring convert pojo to JSON internally? From the…
mailme365
  • 511
  • 2
  • 9
  • 20
11
votes
4 answers

How calculate hashCode of a Pojo by combining hashCodes of it's keys

Consider i have one POJO having String class members : class POJO { String name, address, emailId; equals() { } hashCode() { // How? } } How can i combine hashCodes of my strings to form a hashCode for POJO?
VishalDevgire
  • 4,232
  • 10
  • 33
  • 59
11
votes
2 answers

Jersey 2.0 and Moxy Internal Server Error But No Server Log

I followed the Jersey 2.0 document (https://jersey.java.net/documentation/latest/user-guide.html#json.moxy), modified pom.xml, included jersey-media-moxy artifact, compiled and installed. I could get basic POJO to JSON mapping work for both Produces…
David Bao
  • 136
  • 1
  • 6
11
votes
5 answers

What's the advantage of POJO?

In my project I have a small data structure Key. public class Key implements Serializable { private static final long serialVersionUID = 1L; public String db; public String ref; public Object id; protected Key() { } public…
jackalope
  • 1,554
  • 3
  • 17
  • 37
11
votes
6 answers

Generate JSON sample from POJO

We are looking for a way (maybe existing framework or similar) to generate sample JSON fragments based on POJOs (source or binary). For example: public class foo { String var1; String var2; public String getVar1() { return var1; } …
fnCzar
  • 3,153
  • 4
  • 26
  • 28