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
7
votes
2 answers

jsonschema and date type

I'm just getting started with jsonschema and an example under "Using jsonschema2pojo within your Java project (embedded)" in https://github.com/joelittlejohn/jsonschema2pojo/wiki/Getting-Started having in mind data types of jsonschema listed here…
hhg
  • 649
  • 1
  • 11
  • 20
7
votes
3 answers

Java, Hibernate annotations, How to add methods to POJO object?

I am using hibernate annotations. How to add methods to POJO object? For example i have "getChildNodes" method, associated with database, but i want also add recursive method "getAllChildNodes". I get "org.hibernate.PropertyNotFoundException: Could…
RussianBear
  • 75
  • 1
  • 3
7
votes
1 answer

Should we use jersey-media-json-jackson or jackson-jaxrs-json-provider in Jersey 2.5.1?

According to jersey spec, we can use jersey-media-json-jackson to serialize/deserialize json/pojo, however from some thread in StackOverflow, we can use also jackson-jaxrs-json-provider 2.2.3 Can you please advise which one we should use? Thanks,
duahau
  • 71
  • 1
  • 1
  • 2
7
votes
3 answers

Copy pojo fields to another pojo's setters

Let's say I have class A with public fields x and y. And let's say I have another pojo class B but that uses setters and getters, so it has setX() and setY(). I'd like to use some automatic way to copy from instance of A to B and back. With default…
vertti
  • 7,539
  • 4
  • 51
  • 81
7
votes
9 answers

XStream or Simple

I need to decide on which one to use. My case is pretty simple. I need to convert a simple POJO/Bean to XML, and then back. Nothing special. One thing I am looking for is it should include the parent properties as well. Best would be if it can work…
Adeel Ansari
  • 39,541
  • 12
  • 93
  • 133
7
votes
1 answer

Json to POJO mapping in Android

What are good practice for handling json over a Rest Framework in Android. For instance, if I get a certain json result as follow (or any other, I'm just giving something more complex): {"lifts": [{ "id":26, "time":"2012-11-21T12:00:00Z", …
fneron
  • 1,057
  • 3
  • 15
  • 39
7
votes
4 answers

Java to XSD or XSD to Java

I know that, using JAXB, you can generate Java files from an XSD and that you can also generate the XSD from annotated POJOs. What are the advantages and disadvantages of each? Is one overall better than the other? We basically want to serialize…
Paul Reiners
  • 8,576
  • 33
  • 117
  • 202
7
votes
5 answers

XML to POJO and vice versa

Possible Duplicate: What is the best/simplest way to read in an XML file in Java application? How do I convert XML to POJO and vice versa? does axis2 provide that capability? or does java already have built-in capability for this? or any other…
Java Developer
  • 95
  • 1
  • 1
  • 6
6
votes
1 answer

How to send a POJO as a callback param using PrimeFaces' RequestContext?

I can send callback param(s) and it works perfectly as long as I am only sending some primitive types like String. But the same thing does not work for even the simplest POJO. PrimeFaces guide says that the RequestContext.addCallbackParam() method…
Bhesh Gurung
  • 50,430
  • 22
  • 93
  • 142
6
votes
2 answers

Choosing datatype for field in JSON response

I am working on a Java project which parses a JSON response received from an external API using the Jackson library. One of the fields in the response sometimes comes as a single object and in certain cases, it comes as an array of objects. So I'm…
rakesh
  • 135
  • 3
  • 15
6
votes
2 answers

Spring @RequestBody without using a pojo?

I am using Spring Boot and I have a method defined like this in my controller @PostMapping("/update) public void update(@RequestBody User user) { ... } However in my post request from client(frontend or postman for example), I have something…
theprogrammer
  • 1,698
  • 7
  • 28
  • 48
6
votes
1 answer

Use @Embedded from Room persistence Library beside Gson deserializer

I use Google Room Persistence Library for saving data in database. in Room there is an annotation (@Embedded) : you can use the @Embedded annotation to represent an object that you'd like to decompose into its subfields within a table. You can…
Mneckoee
  • 2,802
  • 6
  • 23
  • 34
6
votes
2 answers

Spring Roo - How to use it without AspectJ?

Is there a way to have Roo generate real POJOs and not AspectJ enhanced ones? I want more PO in my JOs, AJ make it look like POJOOS (POJOs on Steroids) to me
Eran Medan
  • 44,555
  • 61
  • 184
  • 276
6
votes
2 answers

AWS, Lambda, Java, POJO, custom json property name

Making first attempts with Lambda. Created code, deployed, test works, but: public String handleRequest(MyType inObj, Context context) { // logging inObj here } POJO class public class MyType { String prop; String otherProp; } when…
glebsts
  • 337
  • 4
  • 11
6
votes
2 answers

Should serialization logic be in the entity or other class

Where should object serialization logic (the mapping of fields into XML or JSON names and values) be placed? Inside each entity object OR into a different set of classes only concerned with serialization? Any other best practices out there that…
Jose Cifuentes
  • 596
  • 6
  • 21