Łukasz Woźniczka
Łukasz Woźniczka

Reputation: 1695

Hibernate generate random entity

It istrong texts possible to easily generate random entity using hibernate. For example, I have got a simple entity User with 2 fields (name and surname) and I need to create 100 different entities.

Is it possible using Hibernate to create different entities with random fields? And when I have a table Phones with relation ManyToOne with User can I also create 10 different random phones?

Does Hibernate have a class or function to do this?

Upvotes: 3

Views: 925

Answers (2)

sheidaei
sheidaei

Reputation: 10342

You should look at Hibernate as a translator between Object world and Relational world. It doesn't want to manipulate objects, create new objects and so on. Its only task is to ease life of programmers while coding in OO and persisting in Relational. So short answer is NO, it hasn't been built for this purpose.

Upvotes: 0

Alex Barnes
Alex Barnes

Reputation: 7218

This is not a problem that Hibernate has attempted to solve since it is an ORM.

This is an entirely different problem and for the simple case you describe should be fairly easy to do yourself.

However, when you start talking lots of tables and validation etc. this is not a very easy problem at all.

Upvotes: 3

Related Questions