Bug 60 : java.lang.NoSuchMethodError: ... in ... $$EntityBean$h2._ebean_createCopy(Bug.java:1)
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
1.0.3
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
23/01/2009
Updated 
23/01/2009
Type 
Bug
 
Attachments 
No attachments

Exception in thread "main" java.lang.NoSuchMethodError: app.data.Bug.setFixedVersion(Ljava/lang/String;)V
at app.data.Bug$$EntityBean$h2._ebean_createCopy(Bug.java:1)
at com.avaje.ebean.bean.EntityBeanIntercept.createOldValues(EntityBeanIntercept.java:271)
at com.avaje.ebean.bean.EntityBeanIntercept.preSetter(EntityBeanIntercept.java:372)
at app.data.Bug$$EntityBean$h2.setTitle(Bug.java:1)
at main.TestTransient.main(TestTransient.java:14)

 
Rob 23 Jan 08:04
Occurs when

This bug occurs when:
- You use Subclassing (does not occur with Enhanced beans)
- You have a transient field that does not have a matching setter method ...


For example:

...
@Entity
@Table(name = "b_bug")
public class Bug {

...

@Transient
String fixedVersion;

// and have NO setFixedVersion(String m) method


Test program:

Bug bug = Ebean.find(Bug.class, 1);
// change a persistent field... means that Ebean will invoke
// the EntityBeanIntercept.createOldValues() method which invokes
// _ebean_createCopy() on the underlying entity bean
bug.setTitle("modi");

System.out.println("done");

Rob 23 Jan 08:07
Explanation

The _ebean_createCopy() is using a setter method on the transient field that does not exist.

Transient fields of course do NOT have to have any setter or getter methods. Ebean does include support for using Transient fields though because they can be useful with raw @SqlSelect.

... but essentially the fix is to not include @Transient fields in the _ebean_createCopy() method.

Rob 23 Jan 08:44
Fixed in v1.0.3

Fixed in version 1.0.3

woResponse

Upload a file