3

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?

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

maybe i need to use mock for it if i have got one to many relationship
I don't think you want to mock anything. You just need to create instances of your domain structure with random but valid data correct?
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.