2013-12-05 2 views
0

Я использую спящий режим в первый раз. Я создал классы POJO и хотел сопоставить их с db-схемой. Один из этих классов содержат java.util.List других элементов (также объекты POJO), и я получаю следующее сообщение об ошибке:Автоматическое отображение списка Hiberante - сбой hibernate3: hbm2ddl

[ERROR] Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:2.1:hbm2ddl (default-cli) on project webDB: Execution default-cli of goal org.codehaus.mojo:hibernate3-maven-plugin:2.1:hbm2ddl failed: Could not determine type for: java.util.List, for columns: [org.hibernate.mapping.Column(fields)] 

Эта ошибка проявленные Maven сборки вызывающего

mvn hibernate3:hbm2ddl 

Мои классы выглядят это путь:

родитель абстрактный класс:

@MappedSuperclass 
public abstract class WebDBEntity { 

    private Date dateCreated = null; 
    private Date dateModified = null; 
    private String author = null; 
    private String modifier = null; 

    public Date getDateCreated() { 
     return dateCreated; 
    } 
    public void setDateCreated(Date dateCreated) { 
     this.dateCreated = dateCreated; 
    } 
    public Date getDateModified() { 
     return dateModified; 
    } 
    public void setDateModified(Date dateModified) { 
     this.dateModified = dateModified; 
    } 
    public String getAuthor() { 
     return author; 
    } 
    public void setAuthor(String author) { 
     this.author = author; 
    } 
    public String getModifier() { 
     return modifier; 
    } 
    public void setModifier(String modifier) { 
     this.modifier = modifier; 
    } 
} 

Сущности:

Right.java:

@Entity 
public class Right extends WebDBEntity{ 

    @Id 
    @ManyToOne(fetch=FetchType.LAZY) 
    private String name; 
    @Column 
    private String description; 

    public Right(String pName, String pDesc){ 
     name = pName; 
     description= pDesc; 
    } 

    public String getName() { 
     return name; 
    } 
    public void setName(String name) { 
     this.name = name; 
    } 
    public String getDescription() { 
     return description; 
    } 
    public void setDescription(String description) { 
     this.description = description; 
    } 
} 

Group.java:

@Entity 
public class Group extends WebDBEntity{ 

    @Id 
    @Column 
    private String name; 
    @Column 
    private Boolean active; 
    @Column 
    private String description; 
    @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="name") 
    @JoinColumn(name="RIGHT_NAME", nullable=false) 
    private List<Right> rights; 

    public Group(String pName, String pDescr, Boolean pActive) { 
     name = pName; 
     description = pDescr; 
     active = pActive; 
    } 

    public List<Right> getRights() { 
     return rights; 
    } 

    public void setRights(List<Right> rights) { 
     this.rights = rights; 
    } 

    public String getName() { 
     return name; 
    } 
    public void setName(String name) { 
     this.name = name; 
    } 
    public Boolean getActive() { 
     return active; 
    } 
    public void setActive(Boolean active) { 
     this.active = active; 
    } 
    public String getDescription() { 
     return description; 
    } 
    public void setDescription(String description) { 
     this.description = description; 
    } 
} 

и мой ПОМ (без начала):

<name>webDB</name> 

    <properties> 
     <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.jboss.spec</groupId> 
      <artifactId>jboss-javaee-6.0</artifactId> 
      <version>1.0.0.Final</version> 
      <type>pom</type> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.persistence</groupId> 
      <artifactId>persistence-api</artifactId> 
      <version>1.0-rev-1</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.transaction</groupId> 
      <artifactId>jta</artifactId> 
      <version>1.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-core</artifactId> 
      <version>4.2.7.SP1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-entitymanager</artifactId> 
      <version>4.2.7.SP1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-annotations</artifactId> 
      <version>3.5.6-Final</version> 
     </dependency> 

     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-tools</artifactId> 
      <version>3.2.4.GA</version> 
     </dependency> 
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>5.1.27</version> 
     </dependency> 
    </dependencies> 

    <build> 
     <pluginManagement> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-compiler-plugin</artifactId> 
        <version>2.3.2</version> 
        <configuration> 
         <source>1.6</source> 
         <target>1.6</target> 
         <compilerArguments> 
          <endorseddirs>${endorsed.dir}</endorseddirs> 
         </compilerArguments> 
        </configuration> 
       </plugin> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-war-plugin</artifactId> 
        <version>2.1.1</version> 
        <configuration> 
         <failOnMissingWebXml>false</failOnMissingWebXml> 
        </configuration> 
       </plugin> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-dependency-plugin</artifactId> 
        <version>2.1</version> 
        <executions> 
         <execution> 
          <phase>validate</phase> 
          <goals> 
           <goal>copy</goal> 
          </goals> 
          <configuration> 
           <outputDirectory>${endorsed.dir}</outputDirectory> 
           <silent>true</silent> 
           <artifactItems> 
            <artifactItem> 
             <groupId>javax</groupId> 
             <artifactId>javaee-endorsed-api</artifactId> 
             <version>6.0</version> 
             <type>jar</type> 
            </artifactItem> 
           </artifactItems> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 

       <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>hibernate3-maven-plugin</artifactId> 
        <version>2.1</version> 
        <executions> 
         <execution> 
          <phase>process-classes</phase> 
          <goals> 
           <goal>hbm2ddl</goal> 
          </goals> 
         </execution> 
        </executions> 
        <configuration> 
         <components> 
          <component> 
           <name>hbm2ddl</name> 
           <implementation>annotationconfiguration</implementation> 
          </component> 
          <component> 
           <name>hbmdoc</name> 
          </component> 
         </components> 
         <componentProperties> 
          <configurationfile>src/main/resources/hibernate.cfg.xml</configurationfile> 
          <outputfilename>schema.ddl</outputfilename> 
          <drop>false</drop> 
          <create>true</create> 
          <export>false</export> 
          <format>true</format> 
         </componentProperties> 
        </configuration> 
       </plugin> 


      </plugins> 
     </pluginManagement> 
    </build> 

</project> 

То, что я хочу сделать, это создать db и применить его на db, но сейчас я ничего не могу сделать, потому что даже mvn hibernate3: hbm2ddl работает некорректно. Что мне делать?

+0

Попробуйте переместить @JoinColumn аннотации в правый класс на свойстве имени. Я не уверен, что это вызывает вашу ошибку, но я знаю, что так оно и должно быть. – Pace

ответ

Смежные вопросы