Использование доменных объектов Java с плагином Spring Security - PullRequest
0 голосов
/ 30 июля 2009

Я работаю с устаревшей базой данных и соответствующими классами доменов Java. Я пытаюсь добавить Spring Security в приложение, и я бы хотел использовать для этого и доменные классы Java, просто чтобы быть последовательными и держать все вместе. У Grails нет проблем с использованием как POGO, так и POJO, кстати.

Итак, начиная с новой пустой базы данных и нового пустого приложения grails, я добавил Spring Security Plugin (acegi 0.5.1). Тогда я сделал:

grails create-auth-domains org.maflt.ibidem.pojo.Person org.maflt.ibidem.pojo.Authority org.maflt.ibidem.pojo.Requestmap

Это сработало отлично. Мои таблицы были созданы и т. Д. Затем я создал доменные классы POJO. и удалил классы POGO. Затем все скомпилировалось нормально, но когда приложение запустилось, я получил эту ошибку:

2009-07-29 13:35:18,937 [main] ERROR context.ContextLoader  - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: org.maflt.ibidem.pojo.AuthorityPeople.person in org.maflt.ibidem.pojo.Person.authorityPeoples
        at java.security.AccessController.doPrivileged(Native Method)
        at grails.web.container.EmbeddableServer$start.call(Unknown Source)
        at _GrailsRun_groovy$_run_closure5_closure11.doCall(_GrailsRun_groovy:145)
        at _GrailsRun_groovy$_run_closure5_closure11.doCall(_GrailsRun_groovy)
        at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:274)
        at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
        at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:137)
        at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
        at _GrailsRun_groovy.runInline(_GrailsRun_groovy:104)
        at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
        at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:58)
        at RunApp$_run_closure1.doCall(RunApp:33)
        at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
        at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
        at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
        at gant.Gant.withBuildListeners(Gant.groovy:344)
        at gant.Gant.this$2$withBuildListeners(Gant.groovy)
        at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
        at gant.Gant.dispatch(Gant.groovy:334)
        at gant.Gant.this$2$dispatch(Gant.groovy)
        at gant.Gant.invokeMethod(Gant.groovy)
        at gant.Gant.processTargets(Gant.groovy:495)
        at gant.Gant.processTargets(Gant.groovy:480)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: org.maflt.ibidem.pojo.AuthorityPeople.person in org.maflt.ibidem.pojo.Person.authorityPeoples
        at java.security.AccessController.doPrivileged(Native Method)
        ... 23 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: org.maflt.ibidem.pojo.AuthorityPeople.person in org.maflt.ibidem.pojo.Person.authorityPeoples
        at java.security.AccessController.doPrivileged(Native Method)
        ... 24 more
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: org.maflt.ibidem.pojo.AuthorityPeople.person in org.maflt.ibidem.pojo.Person.authorityPeoples
        ... 25 more
2009-07-29 13:35:18,968 [main] ERROR mortbay.log  - Failed startup of context org.mortbay.jetty.webapp.WebAppContext@1dfe1a{/sectest2,C:\src\netbeansprojects\sectest2/web-app}
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: org.maflt.ibidem.pojo.AuthorityPeople.person in org.maflt.ibidem.pojo.Person.authorityPeoples
        at java.security.AccessController.doPrivileged(Native Method)
        at grails.web.container.EmbeddableServer$start.call(Unknown Source)
        at _GrailsRun_groovy$_run_closure5_closure11.doCall(_GrailsRun_groovy:145)
        at _GrailsRun_groovy$_run_closure5_closure11.doCall(_GrailsRun_groovy)
        at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:274)
        at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
        at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:137)
        at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
        at _GrailsRun_groovy.runInline(_GrailsRun_groovy:104)
        at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
        at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:58)
        at RunApp$_run_closure1.doCall(RunApp:33)
        at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
        at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
        at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
        at gant.Gant.withBuildListeners(Gant.groovy:344)
        at gant.Gant.this$2$withBuildListeners(Gant.groovy)
        at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
        at gant.Gant.dispatch(Gant.groovy:334)
        at gant.Gant.this$2$dispatch(Gant.groovy)
        at gant.Gant.invokeMethod(Gant.groovy)
        at gant.Gant.processTargets(Gant.groovy:495)
        at gant.Gant.processTargets(Gant.groovy:480)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: org.maflt.ibidem.pojo.AuthorityPeople.person in org.maflt.ibidem.pojo.Person.authorityPeoples
        at java.security.AccessController.doPrivileged(Native Method)
        ... 23 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: org.maflt.ibidem.pojo.AuthorityPeople.person in org.maflt.ibidem.pojo.Person.authorityPeoples
        at java.security.AccessController.doPrivileged(Native Method)
        ... 24 more
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: org.maflt.ibidem.pojo.AuthorityPeople.person in org.maflt.ibidem.pojo.Person.authorityPeoples
        ... 25 more
2009-07-29 13:35:19,031 [main] ERROR mortbay.log  - Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: org.maflt.ibidem.pojo.AuthorityPeople.person in org.maflt.ibidem.pojo.Person.authorityPeoples:
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: org.maflt.ibidem.pojo.AuthorityPeople.person in org.maflt.ibidem.pojo.Person.authorityPeoples
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessController.doPrivileged(Native Method)
        at grails.web.container.EmbeddableServer$start.call(Unknown Source)
        at _GrailsRun_groovy$_run_closure5_closure11.doCall(_GrailsRun_groovy:145)
        at _GrailsRun_groovy$_run_closure5_closure11.doCall(_GrailsRun_groovy)
        at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:274)
        at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
        at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:137)
        at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
        at _GrailsRun_groovy.runInline(_GrailsRun_groovy:104)
        at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
        at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:58)
        at RunApp$_run_closure1.doCall(RunApp:33)
        at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
        at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
        at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
        at gant.Gant.withBuildListeners(Gant.groovy:344)
        at gant.Gant.this$2$withBuildListeners(Gant.groovy)
        at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
        at gant.Gant.dispatch(Gant.groovy:334)
        at gant.Gant.this$2$dispatch(Gant.groovy)
        at gant.Gant.invokeMethod(Gant.groovy)
        at gant.Gant.processTargets(Gant.groovy:495)
        at gant.Gant.processTargets(Gant.groovy:480)

Мои подписчики POJO:

org.maflt.ibidem.pojo.Person

package org.maflt.ibidem.pojo;

import java.util.List;
import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;
import javax.persistence.Embeddable;

/**
 * <p>Pojo mapping TABLE person</p>
 * <p></p>
 *
 * <p>Generated at Wed Jul 29 11:48:39 MDT 2009</p>
 * @author Salto-db Generator v1.0.16 / EJB3
 * 
 */
@Entity
@Table(name = "person", catalog = "test")
@SuppressWarnings("serial")
public class Person implements Serializable {

    /**
     * Attribute id.
     */
    private Long id;

    /**
     * Attribute version.
     */
    private Long version;

    /**
     * Attribute companyName.
     */
    private String companyName;

    /**
     * Attribute description.
     */
    private String description;

    /**
     * Attribute email.
     */
    private String email;

    /**
     * Attribute emailShow.
     */
    private Boolean emailShow;

    /**
     * Attribute enabled.
     */
    private Boolean enabled;

    /**
     * Attribute passwd.
     */
    private String passwd;

    /**
     * Attribute userRealName.
     */
    private String userRealName;

    /**
     * Attribute username.
     */
    private String username;

    /**
     * List of AuthorityPeople
     */
    private List<AuthorityPeople> authorityPeoples = null;


    /**
     * <p> 
     * </p>
     * @return id
     */
    @Basic
    @Id
    @GeneratedValue
    @Column(name = "id")
        public Long getId() {
        return id;
    }

    /**
     * @param id new value for id 
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * <p> 
     * </p>
     * @return version
     */
    @Basic
    @Column(name = "version")
        public Long getVersion() {
        return version;
    }

    /**
     * @param version new value for version 
     */
    public void setVersion(Long version) {
        this.version = version;
    }

    /**
     * <p> 
     * </p>
     * @return companyName
     */
    @Basic
    @Column(name = "company_name", length = 255)
        public String getCompanyName() {
        return companyName;
    }

    /**
     * @param companyName new value for companyName 
     */
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    /**
     * <p> 
     * </p>
     * @return description
     */
    @Basic
    @Column(name = "description", length = 255)
        public String getDescription() {
        return description;
    }

    /**
     * @param description new value for description 
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * <p> 
     * </p>
     * @return email
     */
    @Basic
    @Column(name = "email", length = 255)
        public String getEmail() {
        return email;
    }

    /**
     * @param email new value for email 
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * <p> 
     * </p>
     * @return emailShow
     */
    @Basic
    @Column(name = "email_show")
        public Boolean getEmailShow() {
        return emailShow;
    }

    /**
     * @param emailShow new value for emailShow 
     */
    public void setEmailShow(Boolean emailShow) {
        this.emailShow = emailShow;
    }

    /**
     * <p> 
     * </p>
     * @return enabled
     */
    @Basic
    @Column(name = "enabled")
        public Boolean getEnabled() {
        return enabled;
    }

    /**
     * @param enabled new value for enabled 
     */
    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    /**
     * <p> 
     * </p>
     * @return passwd
     */
    @Basic
    @Column(name = "passwd", length = 255)
        public String getPasswd() {
        return passwd;
    }

    /**
     * @param passwd new value for passwd 
     */
    public void setPasswd(String passwd) {
        this.passwd = passwd;
    }

    /**
     * <p> 
     * </p>
     * @return userRealName
     */
    @Basic
    @Column(name = "user_real_name", length = 255)
        public String getUserRealName() {
        return userRealName;
    }

    /**
     * @param userRealName new value for userRealName 
     */
    public void setUserRealName(String userRealName) {
        this.userRealName = userRealName;
    }

    /**
     * <p> 
     * </p>
     * @return username
     */
    @Basic
    @Column(name = "username", length = 255)
        public String getUsername() {
        return username;
    }

    /**
     * @param username new value for username 
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * Get the list of AuthorityPeople
     */
     @OneToMany(mappedBy="person")
     public List<AuthorityPeople> getAuthorityPeoples() {
        return this.authorityPeoples;
     }

    /**
     * Set the list of AuthorityPeople
     */
     public void setAuthorityPeoples(List<AuthorityPeople> authorityPeoples) {
        this.authorityPeoples = authorityPeoples;
     }


}

org.maflt.ibidem.pojo.Authority

package org.maflt.ibidem.pojo;

import java.util.List;
import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;
import javax.persistence.Embeddable;

/**
 * <p>Pojo mapping TABLE authority</p>
 * <p></p>
 *
 * <p>Generated at Wed Jul 29 11:48:38 MDT 2009</p>
 * @author Salto-db Generator v1.0.16 / EJB3
 * 
 */
@Entity
@Table(name = "authority", catalog = "test")
@SuppressWarnings("serial")
public class Authority implements Serializable {

    /**
     * Attribute id.
     */
    private Long id;

    /**
     * Attribute version.
     */
    private Long version;

    /**
     * Attribute authority.
     */
    private String authority;

    /**
     * Attribute description.
     */
    private String description;

    /**
     * List of AuthorityPeople
     */
    private List<AuthorityPeople> authorityPeoples = null;


    /**
     * <p> 
     * </p>
     * @return id
     */
    @Basic
    @Id
    @GeneratedValue
    @Column(name = "id")
        public Long getId() {
        return id;
    }

    /**
     * @param id new value for id 
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * <p> 
     * </p>
     * @return version
     */
    @Basic
    @Column(name = "version")
        public Long getVersion() {
        return version;
    }

    /**
     * @param version new value for version 
     */
    public void setVersion(Long version) {
        this.version = version;
    }

    /**
     * <p> 
     * </p>
     * @return authority
     */
    @Basic
    @Column(name = "authority", length = 255)
        public String getAuthority() {
        return authority;
    }

    /**
     * @param authority new value for authority 
     */
    public void setAuthority(String authority) {
        this.authority = authority;
    }

    /**
     * <p> 
     * </p>
     * @return description
     */
    @Basic
    @Column(name = "description", length = 255)
        public String getDescription() {
        return description;
    }

    /**
     * @param description new value for description 
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * Get the list of AuthorityPeople
     */
     @OneToMany(mappedBy="authority")
     public List<AuthorityPeople> getAuthorityPeoples() {
        return this.authorityPeoples;
     }

    /**
     * Set the list of AuthorityPeople
     */
     public void setAuthorityPeoples(List<AuthorityPeople> authorityPeoples) {
        this.authorityPeoples = authorityPeoples;
     }


}

org.maflt.ibidem.pojo.Requestmap

package org.maflt.ibidem.pojo;

import java.util.List;
import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;
import javax.persistence.Embeddable;

/**
 * <p>Pojo mapping TABLE requestmap</p>
 * <p></p>
 *
 * <p>Generated at Wed Jul 29 11:48:39 MDT 2009</p>
 * @author Salto-db Generator v1.0.16 / EJB3
 * 
 */
@Entity
@Table(name = "requestmap", catalog = "test")
@SuppressWarnings("serial")
public class Requestmap implements Serializable {

    /**
     * Attribute id.
     */
    private Long id;

    /**
     * Attribute version.
     */
    private Long version;

    /**
     * Attribute configAttribute.
     */
    private String configAttribute;

    /**
     * Attribute url.
     */
    private String url;


    /**
     * <p> 
     * </p>
     * @return id
     */
    @Basic
    @Id
    @GeneratedValue
    @Column(name = "id")
        public Long getId() {
        return id;
    }

    /**
     * @param id new value for id 
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * <p> 
     * </p>
     * @return version
     */
    @Basic
    @Column(name = "version")
        public Long getVersion() {
        return version;
    }

    /**
     * @param version new value for version 
     */
    public void setVersion(Long version) {
        this.version = version;
    }

    /**
     * <p> 
     * </p>
     * @return configAttribute
     */
    @Basic
    @Column(name = "config_attribute", length = 255)
        public String getConfigAttribute() {
        return configAttribute;
    }

    /**
     * @param configAttribute new value for configAttribute 
     */
    public void setConfigAttribute(String configAttribute) {
        this.configAttribute = configAttribute;
    }

    /**
     * <p> 
     * </p>
     * @return url
     */
    @Basic
    @Column(name = "url", length = 255)
        public String getUrl() {
        return url;
    }

    /**
     * @param url new value for url 
     */
    public void setUrl(String url) {
        this.url = url;
    }



}

org.maflt.ibidem.pojo.AthorityPeople

package org.maflt.ibidem.pojo;

import java.util.List;
import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;
import javax.persistence.Embeddable;

/**
 * <p>Pojo mapping TABLE authority_people</p>
 * <p></p>
 *
 * <p>Generated at Wed Jul 29 11:48:39 MDT 2009</p>
 * @author Salto-db Generator v1.0.16 / EJB3
 * 
 */
@Entity
@Table(name = "authority_people", catalog = "test")
@SuppressWarnings("serial")
public class AuthorityPeople implements Serializable {

    /**
     * Primary key
     */
    private AuthorityPeoplePK authorityPeoplePK;


    /**
     * Get the primary key
     */
    @Basic
    @Id
    public AuthorityPeoplePK getAuthorityPeoplePK() {
        return this.authorityPeoplePK;
    }

    /**
     * set the primary key
     */
    public void setAuthorityPeoplePK(AuthorityPeoplePK authorityPeoplePK) {
        this.authorityPeoplePK = authorityPeoplePK;
    }






    /**
          * <p>Composite primary key for table authority_people</p>
      *
      * <p>Generated at Wed Jul 29 11:48:39 MDT 2009</p>
      * @author Salto-db Generator v1.0.16 / EJB3
      */
    @SuppressWarnings("serial")
    @Embeddable
    public static class AuthorityPeoplePK implements Serializable {

        /**
         * Attribute authority
         */
         private Authority authority;   


        /**
         * Attribute person
         */
         private Person person; 


    /**
     * get authority
     */
            @ManyToOne
            @JoinColumn(name = "authority_id")
            public Authority getAuthority() {
                return this.authority;
            }

            /**
             * set authority
             */
            public void setAuthority(Authority authority) {
                this.authority = authority;
            }       
    /**
     * get person
     */
            @ManyToOne
            @JoinColumn(name = "person_id")
            public Person getPerson() {
                return this.person;
            }

            /**
             * set person
             */
            public void setPerson(Person person) {
                this.person = person;
            }       

        /**
         * calculate hashcode
         */
        @Override
        public int hashCode()
        {
            //TODO : implement this method
            return super.hashCode();
        }

        /**
         * equals method
         */
        @Override
        public boolean equals(Object object)
        {
            //TODO : implement this method
            return super.equals(object);
        }

    }

}

UPDATE

Похоже, проблема связана с AuthorityPeople. Я добавил ключ идентификатора сегрегирования, сделал его первичным ключом и изменил объект на:

package org.maflt.ibidem.pojo;

import java.util.List;
import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;
import javax.persistence.Embeddable;

/**
 * <p>Pojo mapping TABLE authority_people</p>
 * <p></p>
 *
 * <p>Generated at Wed Jul 29 19:34:03 MDT 2009</p>
 * @author Salto-db Generator v1.0.16 / EJB3
 * 
 */
@Entity
@Table(name = "authority_people", catalog = "test")
@SuppressWarnings("serial")
public class AuthorityPeople implements Serializable {

    /**
     * Attribute authority
     */
     private Authority authority;   

    /**
     * Attribute person
     */
     private Person person; 

    /**
     * Attribute id.
     */
    private Long id;


    /**
     * get authority
     */
    @ManyToOne
    @JoinColumn(name = "authority_id")
    public Authority getAuthority() {
        return this.authority;
    }

    /**
     * set authority
     */
    public void setAuthority(Authority authority) {
        this.authority = authority;
    }

    /**
     * get person
     */
    @ManyToOne
    @JoinColumn(name = "person_id")
    public Person getPerson() {
        return this.person;
    }

    /**
     * set person
     */
    public void setPerson(Person person) {
        this.person = person;
    }

    /**
     * <p> 
     * </p>
     * @return id
     */
    @Basic
    @Id
    @Column(name = "id")
        public Long getId() {
        return id;
    }

    /**
     * @param id new value for id 
     */
    public void setId(Long id) {
        this.id = id;
    }



}

и теперь я получаю эту ошибку:

java.lang.NullPointerException: Cannot invoke method list() on null object
        at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
        at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:750)
        at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:727)
        at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:17)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite

Ответы [ 2 ]

0 голосов
/ 07 августа 2009

Я не получил это на работу и до сих пор не видел никаких доказательств того, что кто-то еще имеет. Поэтому я прибегал к перемещению в Граальсе объектов. Но я только что нашел это решение . Я еще не пробовал. Я опубликую свои результаты, как только сделаю.

Кстати, я все еще хотел бы помочь с моей реализацией выше, если кто-то захочет взглянуть на это еще раз.

0 голосов
/ 30 июля 2009

Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: org.maflt.ibidem.pojo.AuthorityPeople.person in org.maflt.ibidem.pojo.Person.authorityPeoples

Звучит как проблема Hibernate, а не Spring Security, или ваш POJO или Grails. Вы это в вашем классе Person:

@OneToMany(mappedBy="person")
public List<AuthorityPeople> getAuthorityPeoples() {
   return this.authorityPeoples;
}

Ваша аннотация ссылается на что-то неправильное?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...