- This topic has 9 replies, 5 voices, and was last updated 18 years, 11 months ago by snpe.
-
AuthorPosts
-
toriwellsMemberHi all,
first of all, I’m sorry if I’m asking something answered before. If so, I have not found it. Well, my question is if there’s any way to generate the *.hbm.xml files directly from the POJOs rather than the DB. I say so because I think the most correct way to create an application (take care this is a personal opinion) is first design it (at the abstract level -interfaces, classes and so on) and then look for the way to store all the information generated by the application. So, if there’s no way to do it by now, I think it would be a great feature for future releases.
Thanks all for your time.
Ramon M. Gallart
Software Engineer.
Riyad KallaMemberif there’s any way to generate the *.hbm.xml files directly from the POJOs rather than the DB.
Not at the moment, but generation of the POJOs from the HBMs and visa-versa has been on our TODO list, sorry for the delay.
snpeMemberRamon,
if there’s any way to generate the *.hbm.xml files directly from the POJOs rather than the DB.
there isn’t unique mapping pojo to hbm
You can use xdoclet, but i think that you want annotations – hibernate annotations are beta now, but ejb3 specification is final and annotations will be final, soon
when use annotations then you needn’t hbm.xml – all is in java – you need jdk > 5.0 for this
Riyad KallaMemberI would point out that annotations are insanely cool and even negate the creation of a DB in some cases (e.g. annotate your code and just run it, hib will create the DB structure necessary to persist the classes on the first run).
I’ve heard this but haven’t tried it first hand yet. Please check the hibernate docs for more info.
KIGParticipantBefore I started a (mid size) Hibernate 2 project last year I faced the same question where and how to start. I decided to design everything in UML and wrote a generator, which created the hbm files. From that point I was able to use the Hibernate Tools to create the POJO’s and the database schema. As a review I would say that this approach worked very well for me because it gave me a maximum flexibility. On the other hand it’s some extra effort, which might be too cost extensive. Another drawback is that you’ve to adapt everything for following Hibernate versions.
Now I started evaluating the Hibernate Mapping from an existing database model. I thing this approach is always useful when you replace an existing application by using the same database.
How do the MyEclipse Team think about the development approach?
Regards,
Klaus
RT04MemberI’m not sure how to handle the following situations:
1. How can I generate the schema from annotated code? The quick start guide only talks about generating POJOs from schema. Is there any other documentation?
2. During development, the POJOs and schema are constantly out-of sync. How do I handle the situation without disturbing existing code?
Thanks
RT04
Riyad KallaMemberRT04 are you referring to Hibernate Annotation docs?
RT04MemberRiyad, That is correct. I’m referring to Hiberanate annotated code.
snpeMemberwhen you make annotation configuration, you need make annotation configuration (like HibernateUtil, just use AnnotationConfiguration) and you can make schema with SchemaExport class (SchemaExport class is part of hibernate, AnnotationConfiguration is part of hibernate annotations projects)
It possible make this step automatic in MyEclipse
snpeMemberwhen you make annotation configuration, you need make annotation configuration
when you make annotation POJO, you need …
-
AuthorPosts