java.lang.ClassCastException: java.lang.Long cannot be cast to
java.lang.String

use Long.parseLong(String) to parse

Sent from my iPad

On Sep 19, 2010, at 7:52 PM, lisandrodc <[email protected]> wrote:

Hi! I have a problem with persist a child class.
The classes are:

The parent class:


@PersistenceCapable

@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public  abstract class Fecha   {

@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key id;
@Persistent
private String nombre;
@Persistent
private Date
@Persistent
private Date fechaFin;

@Persistent(defaultFetchGroup = "true")
List<Partido> partidos;

The child class:

@PersistenceCapable

public class RegFechaUsuario extends Fecha  {

@Persistent
private int puntos;
@Persistent
private Long idUsuarioFecha;
@Persistent
private Long idFechaOriginal;


And the code of run the exception is:
Transaction tx = pm.currentTransaction();
 try {
 tx.begin();

 pm.makePersistentAll(regFechaUsuario);
                     //here is the exception
 tx.commit();

And the regFechaUsuario is created with the build:

public RegFechaUsuario(String nombre, Date fechaIni, Date fechaFin,
  Long idUsuarioFecha, Long idFechaOriginal, List<Partido>partidos)
{
 //super(nombre,fechaIni,fechaFin,partidos);
 this.puntos = 0;
 this.idUsuarioFecha = idUsuarioFecha;
 this.idFechaOriginal = idFechaOriginal;
 this.partidos=partidos;
}

The exception is:
Problem accessing /Prode/JugarFecha.action. Reason:

   java.lang.Long cannot be cast to java.lang.String

Caused by:

java.lang.ClassCastException: java.lang.Long cannot be cast to
java.lang.String
at
org.datanucleus.store.appengine.DatastoreRelationFieldManager.checkForParentSwitch(DatastoreRelationFieldManager.java:
202)
at org.datanucleus.store.appengine.DatastoreRelationFieldManager
$1.setObjectViaMapping(DatastoreRelationFieldManager.java:133)
at org.datanucleus.store.appengine.DatastoreRelationFieldManager
$1.apply(DatastoreRelationFieldManager.java:112)
at
org.datanucleus.store.appengine.DatastoreRelationFieldManager.storeRelations(DatastoreRelationFieldManager.java:
81)
at
org.datanucleus.store.appengine.DatastoreFieldManager.storeRelations(DatastoreFieldManager.java:
955)
at
org.datanucleus.store.appengine.DatastorePersistenceHandler.storeRelations(DatastorePersistenceHandler.java:
546)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.

Regards
Lisandro

-- 
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to