0

I've got a Grails (2.3.8) project that's integrating with a few Java classes. When I attempt to dataBind a one to many relationship, I receive the following error:

{
  "errors": 
  [
    {
      "object": "com.sample.Author",
      "message": "No such field: referencedPropertyType for class: org.codehaus.groovy.grails.orm.hibernate.GrailsHibernateDomainClassProperty"
    }
  ]
}

Does anyone know why the data binding function is trying to bind "referencePropertyType"?

I've included a simplified version of my project with an Author and Books added to the src/java folder.

Author.java

@Entity
public class Author {

    private long _id;
    private List<Books> _books;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "author")
    public List<Book> getBooks() {
        return _books;
    }

    // getters and setters

}

Book.java

@Entity
public class Book {

    private long _id;
    private Author author;

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "AUTHOR_ID", foreignKey = @ForeignKey(name = "author_fk"), nullable = false)
    public Author getAuthor() {
        return _author;
    }

    // getters and setters

}

hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>
        <mapping class="com.sample.Author" />
        <mapping class="com.sample.Book" />
    </session-factory>

</hibernate-configuration>

AuthorController.groovy

class AuthorController {

    def doSomething() {
        def authorInstance = new Author(params)

        if(authorInstance.hasErrors()) {
            println authorInstance.errors as JSON
        }
    }
}
2
  • Don't you want to do it Grails way? Use Domain classes?
    – Mr. Cat
    Jun 6, 2014 at 10:04
  • It's not an option for this project unfortunately. The classes I need to use are shared with other java applications.
    – arcdegree
    Jun 6, 2014 at 15:47

2 Answers 2

0

Does anyone know why the data binding function is trying to bind "referencePropertyType"?

The data binding function is not trying to bind referencedPropertyType. The binder is trying to retrieve that value because the value helps the data binder figure out which types of objects need to be created during data binding.

It looks like there may be a bug with respect to Java domain models in certain circumstances when using the Hibernate plugin. If you file a bug report at https://jira.grails.org/browse/GRAILS and attach a simple sample app, we will get it straightened out.

Sorry for the trouble.

3
  • Could there be a temporary workaround by adding that field specifically in the class? What would it typically look like?
    – arcdegree
    Jun 6, 2014 at 15:49
  • No. The system is not looking for referencedPropertyType in your class. The system is looking for the referencedPropertyType field in GrailsHibernateDomainClassProperty. I expect that the problem is that the system is looking for a field when it should also support a property. If you file a JIRA with a simple app to reproduce the problem, I can fix it. Jun 6, 2014 at 15:55
  • I created a sample application in 2.4.0 and didn't see the issue, so I upgraded my application and it appears to have been resolved.
    – arcdegree
    Jun 6, 2014 at 20:03
0

After upgrading my project from 2.3.8 to 2.4.0 the issue has been resolved. Looks like it was a bug, but upgrading the project fixed the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.