facebook

Hibernate Mapping generation…

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

    Hello.

    I report you something about our use of Hibernate Mapping generation feature.

    I use Eclipse 3.1 (Version: 3.1.0 Build id: I20050627-1435), MyEclipse 4.0 GA,
    JDK 1.5.0_04.

    After the generation of the mapping file and the source file, I have a warning
    in the file generated ([…tablename…].java, not in Abstract[…tablename…].java:
    “The serializable class AtCompany does not declare a static final serialVersionUID field of type long”.

    Fixed in mappedobjectstub.vm in …\eclipse\plugins\com.genuitec.eclipse.hibernate_4.0.0\templates directory.

    ————————

    /**
    * A class that represents a row in the ‘${mappedObject.TableName}’ table.
    * This class may be customized as it is never re-generated
    * after being created.
    */
    public class ${mappedObject.ClassName}
    extends ${mappedObject.AbstractClassName}
    implements Serializable
    {
    /**
    *
    */
    private static final long serialVersionUID = 1L;


    ————————

    In the generation dialog “Create Hibernate Mapping” I would add an option to
    add a ‘lazy’ attribute and his default state (true or false) to the sets.

    At the end of the process of generation there is a switch to the MyEclipse perspective.
    I would like to switch my previous perspective.

    Regards,
    Alberto Santini

    #236892 Reply

    Riyad Kalla
    Member

    Alberto,
    1) The serialized warning is new with Eclipse 3.1, you’ll notice it in quite a few of your existing projects. Using a static generated value like 1L isn’t very accurate or helpful and may give people a false sense of “Correctness”, so we opted to not generate a UID at all and let the users do it if they intended to keep the versioning of the classes up to date.

    2) Lazy default is probably a good suggestion.

    3) Perspective switching, I’ll look into it.

    #236939 Reply

    Thanks for the reply.

    We are switching from Hibernate Synch plugin to MyEclipse feature to generate java classes from the db tables. So we are using a lot the tool: 89 hbm, 200+ queries, etc.

    1 (serialzed warning): ok… it was a quick fix… I think it’s not good to edit generated source. There is the quick fix of Eclipse to generate a unique long: you can call internally that part of code for the generation.

    2 (lazy default): In Hibernate 3 the default (and best practice) is lazy=”true”. In Hibernate 2 it was lazy=”false”. May be it could be an option not so used.

    3 (perspective swicth): This is annoying! 🙂 Every time passing from MyEclipse to Java perspective.

    4 NEW (hibernate configuration): If you generate the code selecting to update the hibernate file configuration, MyEclipse adds in the same line the mapping resource element.

    5 NEW (overwrite option): Every time the generation overwrites the .hbm and .java generated. May be it’s better to add an option.

    6 NEW (hbm or hbm.xml): Add an option to choice the extension of the mapping file: .hbm or hbm.xml or something else.

    Regards,
    Alberto.

    #236945 Reply

    Riyad Kalla
    Member

    Thank you Alberto for the feedback.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Hibernate Mapping generation…

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