Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persistence Exception when using pojo binding in play framework controller

I have the following entity:

@Entity
public class Client extends Model{
   public String email;
   public String password;
}

I have the following controller :

public static void  clientSignUp(models.Client client)
{
     info("Client email" + client.email);
     info("Client password" + client.password);
     client.create();
}

When this controller is called, the two logs print out correctly. But the client.create line errors with this hibernate exception:

  PersistenceException occured : org.hibernate.PropertyAccessException: 
  could not get a field value by reflection getter of models.Client.email

However, when i change the code slightly to :

   public static void  clientSignUp(models.Client client)
   {
    models.Client client2  = new Client();
    client2.email= client.email;
    client2.password = client.password;
    client2.create();
   }

It works. Any ideas why?

like image 567
Karthik Ramachandran Avatar asked Nov 04 '22 11:11

Karthik Ramachandran


1 Answers

I may be be a few months late to answer this, but I ran into a similar issue and was able to fix it. To get the context right, here was my environment:

  1. I was initializing a model instance in a Bootstrap Job.
  2. I was in DEV mode, hence was using an in-memory database (db=mem)

I tried all of the above options (.create(), .save(), .merge()) - none of it worked for me. Nor did an application re-start.

Finally, what did the trick was clearing the /tmp directory and a restart of the app.

like image 72
curioustechizen Avatar answered Nov 09 '22 14:11

curioustechizen