[google-appengine] Updating problem with unkowned relation

2011-08-29 Thread Bat
I've 2 simple classes :

public class Student {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
   com.google.appengine.api.datastore.Key key;
@Persistent
   public String firstName;
@Persistent
   public String lastName;
}
And

public class Teacher {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
com.google.appengine.api.datastore.Key key;
@Persistent
public String firstName;
@Persistent
public String lastName;
@Persistent
public com.google.appengine.api.datastore.Key student;
}

First, I create a Teacher with only the fields 'firstname' &
'lastname' filled. It works. Then, I update my teacher with this
code :

Transaction tx = pm.currentTransaction();
  tx.begin();
  Teacher a = pm.getObjectById(Teacher.class,
KeyFactory.stringToKey( the_key));
  if(a != null) {
  try {
  a.setFirstName("test");
  a.setLastName("test");
  a.student = KeyFactory.stringToKey( req.getParameter("student101-
key"));
  tx.commit();
  }
  }
  pm.close();
  }
  }
After this transaction, the fields "firstname" & "lastname" are
correctly updated. However, the field "student" is still null. Do you
know Why?

Thank you very much

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



[google-appengine] Problem with blobstoreService.getUploadedBlobs(request)

2011-09-28 Thread Bat
Hi,

I've a problem with the methode blobstoreService.getUploadedBlobs().
I've a JSP page in wich one I set an uploader like this :



//...and multiple input for text


and I retrieve this code with my servlet :

java.util.Map blobs =
blobstoreService.getUploadedBlobs(req);
BlobKey blobK  = blobs.get("myFiles[]"); //I don't know why I need to
add the characters 's[]' at the end...

But the behavior is strange. The first time I upload an image,
everything works. However, the second time, I send my form without
uploading somehting (only text data), and then my java code finds a
BlobKey. But this BlobKey seems to be the previous sended data, or a
corrupted data.
I mean that not normal, because when I deploy this version on my
localhost, if the form uploads no file the method getUploadedBlobs
returns an empty HashMap. However, when I deploy on google servers, if
the form uploads no file, the method getUploadedBlobs seems  to return
a HashMap with wrong data.

Could you help me? Or tell me if this behaviro is normal...

Many thanks,

bat

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



[google-appengine] Re: Problem with blobstoreService.getUploadedBlobs(request)

2011-09-29 Thread Bat
I think that in all cases, if I send a form without file inside,
google blobstore create an empty blob...
I can see it in Blobstore vievwer.

This strange behavior is only on the google server, not on
localhost...

On 28 sep, 17:25, Bat  wrote:
> Hi,
>
> I've a problem with the methode blobstoreService.getUploadedBlobs().
> I've a JSP page in wich one I set an uploader like this :
>
> 
> 
> //...and multiple input for text
> 
>
> and I retrieve this code with my servlet :
>
> java.util.Map blobs =
> blobstoreService.getUploadedBlobs(req);
> BlobKey blobK  = blobs.get("myFiles[]"); //I don't know why I need to
> add the characters 's[]' at the end...
>
> But the behavior is strange. The first time I upload an image,
> everything works. However, the second time, I send my form without
> uploading somehting (only text data), and then my java code finds a
> BlobKey. But this BlobKey seems to be the previous sended data, or a
> corrupted data.
> I mean that not normal, because when I deploy this version on my
> localhost, if the form uploads no file the method getUploadedBlobs
> returns an empty HashMap. However, when I deploy on google servers, if
> the form uploads no file, the method getUploadedBlobs seems  to return
> a HashMap with wrong data.
>
> Could you help me? Or tell me if this behaviro is normal...
>
> Many thanks,
>
> bat

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



[google-appengine] Re: Problem with blobstoreService.getUploadedBlobs(request)

2011-09-29 Thread Bat
Indeed...

Does anyone solve that problem?


On 29 sep, 13:22, Stuart Langley  wrote:
> Probably you are
> seeinghttp://code.google.com/p/googleappengine/issues/detail?id=4548

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



[google-appengine] Attachment in mail

2011-12-12 Thread Bat
Hi,

One of my servlet creates CSV content in a String variable.

I'd like to send this CSV like an attachment file but everybody knows
the limitations of GAE : it's impossible to create a file. So, I
decided to find an another solution.

Mine is to attach the CSV string like that :
String csv = "";
Message msg = new MimeMessage(session);
msg.setDataHandler(new DataHandler(new
ByteArrayDataSource(csv.getBytes(),"text/csv")));
msg.setFileName("data.csv");

I receive the mail but without attachment. The CSV string is
integrated into the body part of the mail.

How to attach this CSV string like a CSV file into the mail?

Thanks

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



[google-appengine] One-to-many relation problem

2012-03-30 Thread Bat
Hi All,

I'm trying to use the one-to-many relation with heritance but without
success. Let me explain.

I have 3 classes :

@PersistenceCapable
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public abstract class Op {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
public Key key;

@Persistent(mappedBy = "op")
@Element(dependent = "true")
private ArrayList entryArr = new ArrayList();
}

 @PersistenceCapable
public class ExtendedOp extends Op {
public double quota;
}

@PersistenceCapable
public class Entry {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
public Key key;

@Persistent
private Op op = null;
}

When I persist, I use this code :
ExtendedOp op = new ExtendedOp();
op.addNewEntry(new Entry());
op.addNewEntry(new Entry());
pm.makePersistent(op);

After, I persisted, I reload the "ExtendedOp" with this :
String connectionQuery = "select from " + ExtendedOp.class.getName();
 opArr = (List) pm.newQuery(connectionQuery).execute();
 if (opArr != null) {
for (ExtendedOp opExt : opArr) {
if ( opExt.getEntryArr() != null)
for (Entry entry : sale.getEntryArr()) {
System.out.println("ok"); //works!
if (entry.getOp() != null)
System.out.println("perfect"); //never
display
}
}
}

The problem is : the Entry has the field "operation" always null. This
field is from the relation one-to-many. Maybe this field is still null
because is class type is "parent" of ExtendedOp?

Could you help me to solve that problem?

Thanks you very much,

Bat

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



[google-appengine] One-to-many relation problem

2012-03-30 Thread Bat
 

Hi All,


I'm trying to use the one-to-many relation with heritance but without

success. Let me explain.


I have 3 classes :


@PersistenceCapable

@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)

   public abstract class Op {

   @PrimaryKey

   @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)

   public Key key;


   @Persistent(mappedBy = "op")

   @Element(dependent = "true")

   private ArrayList entryArr = new ArrayList();

}


@PersistenceCapable

public class ExtendedOp extends Op {

   public double quota;

}


@PersistenceCapable

public class Entry {

@PrimaryKey

@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)

public Key key;


@Persistent

   private Op op = null;

}


When I persist, I use this code :

ExtendedOp op = new ExtendedOp();

op.addNewEntry(new Entry());

op.addNewEntry(new Entry());

pm.makePersistent(op);


After, I persisted, I reload the "ExtendedOp" with this :

String connectionQuery = "select from " + ExtendedOp.class.getName();

opArr = (List) pm.newQuery(connectionQuery).execute();

if (opArr != null) {

   for (ExtendedOp opExt : opArr) {

   if ( opExt.getEntryArr() != null)

   for (Entry entry : sale.getEntryArr()) {

   System.out.println("ok"); //works!

   if (entry.getOp() != null)

   System.out.println("perfect"); //never

display

   }

   }

   }


The problem is : the Entry has the field "operation" always null. This

field is from the relation one-to-many. Maybe this field is still null

because is class type is "parent" of ExtendedOp?


Could you help me to solve that problem?


Thanks you very much,


Bat

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/i_qtiXxQ4cYJ.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.