-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Issues during generation metamodel
PostPosted: Fri Nov 19, 2010 11:28 am 
Newbie

Joined: Fri Nov 19, 2010 11:13 am
Posts: 2
Hello all,

I'm currently facing with incorrect metamodel generation for following case:

My entities classes:

Code:
@MappedSuperclass
public class AbstractFoo {
    @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY, optional = true)
    @JoinColumn(name = "DOO_ID", nullable = true)
    protected Doo doo;

    public int hashCode() {
       //hashCode impl
    }

    public boolean equals(Object obj) {
       //equals impl
    }
//getters and settert
}


Code:
@Entity
@Table(name="Entity")
public class Entity extends AbstractFoo {
    /**
     * Primary key.
     */
    @TableGenerator(name = "Emp_Gen", table = "ID_GEN", initialValue=10000, pkColumnName = "GEN_NAME", valueColumnName = "GEN_VAL")
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "Emp_Gen")
    @Column(name = "ID")
    protected Integer id;

//rest of properties with getters and setters
}


Maven metamodel plugin configuration:

Code:
<plugin>
            <groupId>org.bsc.maven</groupId>
            <artifactId>maven-processor-plugin</artifactId>
            <version>1.3.5</version>
            <executions>
               <execution>
                  <id>process</id>
                  <goals>
                     <goal>process</goal>
                  </goals>
                  <phase>generate-sources</phase>
                  <configuration>
                     <outputDirectory>target/metamodel</outputDirectory>
                     <processors>
                        <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
                     </processors>
                  </configuration>
               </execution>
            </executions>
         </plugin>


I am expection following metamodel result:
Code:
@StaticMetamodel(AbstractTenantEntity.class)
public abstract class AbstractFoo_  {

public static volatile SingularAttribute<AbstractFoo, Doo> doo;

}

but actual result is
Code:
@StaticMetamodel(AbstractTenantEntity.class)
public abstract class AbstractFoo_ {

   public static volatile SingularAttribute<AbstractFoo, Integer> hashCode;

}


What wrong with my code?

Thanks,
Toxa


Top
 Profile  
 
 Post subject: Re: Issues during generation metamodel
PostPosted: Tue Nov 30, 2010 12:47 pm 
Newbie

Joined: Tue Nov 30, 2010 12:38 pm
Posts: 2
Hi taxo, I'm having the same problem. On the Doo side, the
Code:
ListAttribute<Doo, AbstractFoo> Doo_.abstractFoos
is well generated, but I'm lacking the AbstractFoo_.doo.

Have you solved it yet ?


Top
 Profile  
 
 Post subject: Re: Issues during generation metamodel
PostPosted: Tue Nov 30, 2010 2:39 pm 
Newbie

Joined: Fri Nov 19, 2010 11:13 am
Posts: 2
No.


Top
 Profile  
 
 Post subject: Re: Issues during generation metamodel
PostPosted: Tue Nov 30, 2010 2:45 pm 
Newbie

Joined: Tue Nov 30, 2010 12:38 pm
Posts: 2
Apparently, by not declaring the @javax.persistence.Access, it assumed I was using PROPERTY instead of FIELD. By default when not specified, the access type is deduced by where you put the @Id annotation (on a field or on a method).

I'm using Spring-Roo with Hibernate, so Roo automatically adds me an @Id Long id if I don't specify an @Id on my own, but it is added by a Roo-generated aspect outside the .java, and I guess jpamodelgen is not taking it into account whenit generates the sources ; indeed maven seems to weave aspects after source generation… thus jpamodelgen, not finding @Id, seems to default to PROPERTY when I'm using FIELD.

TL;DR try adding this annotation to your entity:
Code:
@javax.persistence.Access(javax.persistence.AccessType.FIELD)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.