Is there a way to use java code and those hibernate entity classes to create fixture data.
开发者_如何学CI find using import.sql is not good when it comes to database migration
Since you are using hibernate, the way to create sample data is to use hibernate itself to create it. You have two options:
- generate random data - look from 1 to X, instantiate entities and set random values, then save each entity
- predefined data - use some meta format, like .properties, .json or .xml to define field=value pairs, parse that file, instantiate entities for each record, set the fields, and save it.
That way your data generation is tied to your entity model, and when the model changes, your data won't become out-of-sync.
精彩评论