facebook

Hibernate POJOs

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #227223 Reply

    markericksen
    Member

    I’m new to Eclipse and Hibernate so forgive me if this has already been discussed.

    In my first example program I created a database and used the myeclipseide database manager to generate Hibernate classes.

    For each table, two classes were made. The first being an abstract class with comments in the class indicating that this file should not be edited and the second file free for the developer to edit.

    Questions:

    How can I just create one POJO object per table?
    When will myeclipseide be free from the “soft lock”* it wants on the interface files?

    *In many development environments, different developers modify the same files. Different developers use different tools and some don’t like IDEs at all. An IDE should not inject its wishes on the code and assume it is the only editor for any file.

    #227239 Reply

    Riyad Kalla
    Member

    How can I just create one POJO object per table?

    You can’t, although we might evaluate this as an enhancement for future release. The reason we don’t want to go down this path is because people may use this setting accidentally, heavily modify their classes, then re-gen from the DB and have all their changes overwritten which would be considerably more damaging then simply having “too many classes”.

    When will myeclipseide be free from the “soft lock”* it wants on the interface files?

    Please clarify what you mean. This was an active decision we made, not one out of technical limitations.

    An IDE should not inject its wishes on the code and assume it is the only editor for any file.

    Agreed, however you are attempting to use the IDE to make your life easier by generating your mapping files. If that is the case, the IDE is providing you that functionality in the friendliest way it can: by giving you an overwritable base class that it generates and then an extended class for you and your team to safely modify without concern that someone on the team may regenerated the base mappings during development.

    If it is that important to your team to not have these base classes, then I highly suggest you use XDoclet to markup your POJOs yourself, then run XDoclet to generate the hbm.xml files, this is what I tend to do. The downside is all the manual maintenence, but if you want to keep track of EXACTLY what is happening, that’s a good way to do it.

    #227246 Reply

    markericksen
    Member

    Thanks for the reply.

    I asked these questions because this is the first IDE I’ve used that behaves this way. Other IDEs I’ve used will auto-synchronize or re-parse when a file its concerned with changes. There are no demands that the file not be changed by the programmer. The IDE is supposed to work with the programmer not control the programmer. This is because, as I said, there may be others on the same project not using an IDE so some of the restricted files will get changed anyway (in spite of the warning).

    Regarding Hibernate, as I read about the technology, one thing that stood out to me was the idea of using Plain Old Java Objects (POJOs) to represent a table row. It is supposed to be one file, not two, to keep things simple. If your concern is about overwriting files, then other IDEs I’ve used just warn the user of a potential overwrite and even offer to merge the changes through a more sophisticated merging tool. Again, working with the programmer, not controlling the programmer.

    These are things to keep in mind and hopefully (from my point of view) pursue in future versions.

    #250960 Reply

    dkittle
    Member

    +1 for only generating a single POJO to represent a table. I realize that some devs might overwrite a changed class but there are many other instances were they might do the same (changes to XDoclet generated classes are a classic example of this problem). You could put some comments at the top of the generated file and maybe even pop up a warning dialog when auto-gen is done (that existing POJOs will be overwritten).

    We haven’t been using the auto-gen feature of MyEclipse specifically because of the use of abstract base classes 🙁

    #250971 Reply

    Haris Peco
    Member

    just unckeck ‘ generate abstract class’ in 1st page of hibernate wizard

    Best regards

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Hibernate POJOs

You must be logged in to post in the forum log in