Custom POJO manufacturer Podam (extension to TypeManufacturer)

111 views
Skip to first unread message

simar...@cleartax.in

unread,
Dec 28, 2016, 1:47:28 PM12/28/16
to PODAM
Adding TypeManufactures strategies gives you liberty to instantiate the POJO, but Podam repopulates the Pojo with random values after creation. (I am aware of Attribute strategy but i dont want to introduce Podam annotations in my Entity classes.)

Is there a way to return pre-constructed, pre manufactured POJO which will not be repopulated by Podam? I want to do that only for some entities, not all.

Daniil Ivanov

unread,
Dec 28, 2016, 3:05:24 PM12/28/16
to PODAM
Yes, Podam does populate all properties it found after object instantiation. It's done like this because in Podam approach object creation should not be customized that much, but filling object properties should be.

But population happens with help of the same type manufacturers, so you can feed desired values to the specific properties.

Another option would be to implement custom ClassInfoStrategy, which would return empty property set fot the class efficiently skipping population.

Anyway I would like to know more on the context of the task, when you want to do only instantiation without population.

simar...@cleartax.in

unread,
Dec 29, 2016, 3:21:22 AM12/29/16
to PODAM
I am using PODAM to populate mysql database with by HIbernate ORM at the application side. There were two use cases of only instantiation without population:-

1. I need to feed some static POJO (like City POJO's). A City object will have name, pincode, state already set.
2. When there are relations between entities, I wanted to control the randomness, As In "every time creating a new Object of child entity" Vs "Feeding from the pool of already  created child entities by Podam".

Daniil Ivanov

unread,
Dec 30, 2016, 6:06:07 AM12/30/16
to PODAM
Not really sire what static POJO means in this context. In case you want more control on POJO population feel free to create a new request for this.

The second option sounds a bit vague. And the second sentence describes Podam behaviour with memoization being disabled and enabled.
But my guess would be this is the same as the issue #89
Reply all
Reply to author
Forward
0 new messages