facebook

Generating typed Sets like "Set children&q

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

    Hello,

    When I do a hibernate reverse engineering, my relations are transformed to:

    
        private Set bodies = new HashSet(0);
    ...
        public Set getBodies() {
            return this.bodies;
        }
    
        public void setbodies(Set bodies) {
            this.bodies = bodies;
        }
    

    But I’d like to have a more strongly typed collection with JDK5 generics like:

    
        private Set<Body> bodies = new HashSet<Body>(0);
    ...
        public Set<Body> getBodies() {
            return this.bodies;
        }
    
        public void setbodies(Set<Body> bodies) {
            this.bodies = bodies;
        }
    

    I saw a similar post where you updated PojoFields.vm and such but I don’t see how I can get the target Type Name (here: Child)

    Is there a way to generate it this way automatically or can you indicate how I could change the .vm files to achieve this ?

    Thanks.

    #278547 Reply

    I found the answer !

    1. Create a custom template by following instructions in Help section “5.5 Using templates to fine tune generated code”
    2. Edit PojoFields.vm and change all $jdk5 to true
    3. Edit PojoPropertyAccessors.vm and do the same change.

    There is probably a better way to make $jdk5 true and I would be glad to know it but this solution is good enough for me.

    #278606 Reply

    Loyal Water
    Member

    Thank you for posting the solution.

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Generating typed Sets like "Set children&q

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