[appengine-java] Re: jdo and pm.close()?

2010-07-11 Thread boustanihani
Not the Manager is created once but the ManagerFactory!
Managers should be created and ended each time data-access is needed!

I think you should call pm.commit() after calling makePersistent() ...
because after that u r sure that your data has been written!
I would be glad to hear your feedback.

regards
Hani

On Jul 12, 6:45 am, Ronmell Fuentes  wrote:
> Hi Andres.
> when you build a PersistenceManager, the instance must be done just once
> during the call in your method, class, etc., so, if you want to continue
> with doing more tasks with it, it's ok. just when the call to your manager
> class is ended then you can delete or end the manager, otherwise you can
> keep using it. Remember the process of building the manager is done just
> once in your whole app, but the instances can be many.
>
> Rgds.
>
> R
>
> 2010/7/11 Andrés Cerezo 
>
>
>
>
>
> > If i want to execute this source code without errors, I have to delete the
> > first pm.close(); Anyone knows why?
>
> >           final Date date = new Date();
> > EmployeeData employee = new  EmployeeData("John", "Doe", date);
>
> >           PersistenceManager pm = PMF.get().getPersistenceManager();
>
> >           final Long id = pm.makePersistent(employee).getId();
>
> >           // From a different persistence manager, look up the // object
>
> >           employee = pm.getObjectById(EmployeeData.class, id);
> >           assertEquals(employee.getFirstName(), "John");
> >           assertEquals(employee.getLastName(), "Doe");
>
> >           pm.close();
>
> >          pm = PMF.get().getPersistenceManager(); */
>
> >           EmployeeData employee2 = new EmployeeData("John2", "Doe2", date);
>
> >           final Long id2 = pm.makePersistent(employee2).getId();
>
> >           // From a different persistence manager, look up the // object
>
> >           employee2 = pm.getObjectById(EmployeeData.class, id2);
> >           assertEquals(employee2.getFirstName(), "John");
> >           assertEquals(employee2.getLastName(), "Doe");
>
> >           pm.close();
>
> > Thanks.
>
> > --
> > 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
> > google-appengine-j...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengine-java+unsubscr...@googlegroups.com > unsubscr...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine-java?hl=en.
>
> --
> ausencia de evidencia  ≠  evidencia de 
> ausenciahttp://culturainteractiva.blogspot.com/

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: how should I design my data model for following scenario

2010-07-11 Thread Parvez
Thanks Robert.
I don’t think that will solve it.
I think text search could have solved it easily, which is not in at
the moment, unfortunately.

If I design it something like this (Item as concatenated strings of
items separated by a space):

InvoiceNo  Item InvoiceDate

10  item_a
11  item_a item_b item_z
12  item_a item_c item_x
13  item_a item_x


I am not sure how text search will work or going to look like when in,
but just say may be something like this

SELECT * FROM  Invoice WHERE item CONTAINS(“item_a”, “item_b”) AND
InvoiceDate >= someDate AND  InvoiceDate < someOtherDate

I implemented search as suggested in various posts/blog, but that is
not working as I have a range scan as well and due to that GAE always
put range scan in the end and that result in lots of indexes.

e.g.
If I have one item to search in invoice then it will need following
index (even in query if I put date filter first, then still it will
put date scan in end, as range is last, otherwise I could get away
with one large index)






If I have 2 items to search then it needs



   



and so on.

Any thoughts/suggestions?

On Jul 11, 1:55 pm, Robert Lancer  wrote:
> I dont fully understand the problem, but you might want to look into
> using the IN filter option that can take a list of items and return
> the associated entities, if the list is small enough you can cook up
> the set operations in memory.
>
> On Jul 11, 6:58 am, Parvez  wrote:
>
> > I want retrieve invoice numbers depending upon items e.g.
>
> > InvoiceNo        Item          InvoiceDate
>
> > 10      item_a
> > 11      item_a
> > 11      item_b
> > 11      item_z
> > 12      item_a
> > 12      item_c
> > 12      item_x
> > 13      item_a
> > 13      item_x
>
> > User can search on item(s) and can also include period (invoice date)
> > as part of search.
> > Initially, I tried using list property for Item, it worked but then it
> > failed once more than 6, 7 items included in query along with date
> > i.e. "Too many indexed properties for entity.." [:-) then I found out
> > that I can not delete index in java, using java sdk 1.3.5, it works
> > locally, but does not work when application uploaded]
>
> > In above example if user query for "item_a" and  "item_b" then I
> > should only get invoice number 11.
> > Any suggestion how can I achieve this?
> > Thanks.

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Task Queues and other services in jetty

2010-07-11 Thread Miroslav Genov

Any ideas ?

Regards,
  Miroslav


On 07/10/2010 08:36 PM, Miroslav Genov wrote:

Hello,
My general idea of doing this in jetty instead of GAE's local 
development server is that I want to spin up the development server 
from my test. To handle that, I made a custom ApiProxy.Delegate that 
could be cleared after test finishes it's execution.


The issue that I'm encountering is that I cannot test task queue 
execution from my tests. I suppose that GAE development server is 
registering it's own servlets and filters that are simulating gae 
services locally - task queues, datastore, memcache and etc. My 
problems is that I don't know which ones are they. It seems that 
appengine-local-runtime.jar contains a webdefault.xml file which 
contains all registered servlets and filters, but I don't know whether 
they are for the service emulation or they are for the administrative 
interface only. Can anyone give me a clue about this ?


Here is a small snippet from my code, that is illustrating what I'm 
doing:

server = new Server(port);
Context root = new Context(server, "/", Context.SESSIONS);
root.setResourceBase("web");

// we have to attach a gae emulation filter that is installing
// all required local services.
root.addFilter(new FilterHolder(new Filter() {

 MyAppLocalServiceTestHelper helper = new EvoAdmLocalServiceTestHelper();
  //init and destroy definitions are empty
  .
  public void doFilter(ServletRequest servletRequest, ServletResponse 
servletResponse, FilterChain filterChain) throws IOException, 
ServletException {

  // GAE  local services setup
   // Initializes a custom datastore Delegate which may clean it's 
state after the test was executed.

  helper.setUp();
  filterChain.doFilter(servletRequest, servletResponse);
  }

   }),"/*",0);

root.addFilter(GuiceFilter.class, "/*", 0);
root.addServlet(DefaultServlet.class, "/");




Regards,
   Miroslav



--
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Have to restart server to see changes when using Spring

2010-07-11 Thread decitrig
I have this controller set up right now, using Spring MVC 3.0:

@Controller
public class HelloController {

  @RequestMapping("/hello.htm")
  public String hello() {
return "helloView";
  }
}

It works fine - navigating to that link tries to call up the helloView
view. However, if I want to make a change (like switching the return
value to "helloView1") I have to stop and restart the process in
Eclipse. Making changes to e.g. index.jsp in the war/ directory are
refreshed just fine. Is there something special I need to do for
Spring? I'm just getting started with it & with GAE, so I'm probably
just doing something blinkered. Everything seems to *work* fine, I
just have to restart for changes to be displayed.

--
decitrig

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: can't figure out how to use JSTL to escape xml (guestbook tutorial)

2010-07-11 Thread decitrig
On Jul 7, 10:55 am, "Ikai L (Google)"  wrote:
> If you already have EL enabled with this tag at the top of your page:
>
> <%@ page isELIgnored="false" %>
>
> Can't you just use this?
>
> ${g.content}
>

I tried that - just empty output. I was able to get it to work by
doing pageContext.setAttribute(). It seems like there are better ways
(i.e. Spring, which I'm working on now.

>
> On Mon, Jul 5, 2010 at 9:44 PM, decitrig  wrote:
> > In the tutorial, I've added the following to the guestbook.jsp file:
>
> > <%@ taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c" %>
>
> > and made changed this:
>
> > <%= g.getAuthor().getNickname() %> wrote:
> > <%
> >            }
> > %>
> > 
> > <%
> >        }
> >    }
> >    pm.close();
> > %>
>
> > I get no output from the c:out tag. I've tried a bunch of different
> > variations and nothing seems to work: I can get a medley of my
> > favorite exceptions, or no output, or the the literal text of the
> > expression I was hoping to evaluate. I have searched around, and I can
> > confirm the following:
>
> > I have isELIgnored="false", I do not have any JSLT jar in my WEB-INF/
> > lib directory. I also tried a  > class="guestbook.Greeting" /> tag, but I got an error about the value
> > for the "class" attribute being invalid. Please help? I'm happy to
> > provide additional code or debugging output, if someone can point me
> > in the right direction.
>
> > PS. Might I respectfully submit that this would be a good thing to
> > include in the tutorial?
>
> > --
> > 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
> > google-appengine-j...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengine-java+unsubscr...@googlegroups.com > unsubscr...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine-java?hl=en.
>
> --
> Ikai Lan
> Developer Programs Engineer, Google App Engine
> Blog:http://googleappengine.blogspot.com
> Twitter:http://twitter.com/app_engine
> Reddit:http://www.reddit.com/r/appengine

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: generating sequence for persistence classes like Country and so on ...

2010-07-11 Thread cscsaba
Hello Hariharan,

I need the way, which can instruct the JPA using the xml, flat file
ids as unique identifier.
Since I'm not able to use the find() which is rely on the key field.
With the following JPA annotation generating ids get out of my
control.
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)

It seems to me my english is not enough to explain what is the point
in this case or the answer is trivial for others.


On júl. 11, 06:30, Hariharan Anantharaman
 wrote:
> In my application, instead of flatfile, i used XML to have the key and value
> (again these entries are used for drop down) and i read the values using
> xPath api's.  Given that the country list is static as said before, i guess
> it should be work fine.
>
> Thanks
> Hari
>
> 2010/7/10 cscsaba 
>
> > Hello,
>
> > I dont know the way of generating sequence 1,2,3 for countries by JPA.
> > It generates keys which are not agree with country codes.
> > Sorry, I was not clear enough.
>
> > On júl. 9, 09:51, Nacho Coloma  wrote:
> > > That seems like good advice. For this concrete use case there is a
> > > country list included with your JDK:
>
> > > Locale[] locales = Locale.getAvailableLocales();
> > > for (Locale locale : locales) {
> > >     countries.add(new Option(locale.getCountry(),
> > > locale.getDisplayCountry(currentLocale)));
>
> > > }
>
> > > On Jul 8, 7:11 pm, "Ikai L (Google)"  wrote:
>
> > > > Why not just load these from a flatfile and load it into local memory?
> > The
> > > > number of countries in the world is something that changes very
> > > > infrequently.
>
> > > > On Mon, Jul 5, 2010 at 12:28 PM, cscsaba 
> > wrote:
> > > > > Hello,
>
> > > > > What is the best practice to generation sequence ids for persistence
> > > > > classes like Country's id (for Country drop down)?
> > > > > I mean:
> > > > >   1.Hungary
> > > > >   2.US
> > > > >   3.Spain
>
> > > > > The well known Toplink annotation help suggest the following.
>
> > > > > @SequenceGenerator(name="CUST_SEQ", allocationSize=25)
> > > > > @GeneratedValue(strategy=SEQUENCE, generator="CUST_SEQ")
>
> > > > > But the SEQUENCE strategy is invalid (underlined by Eclipse)
>
> > > > > Is there any real world GAE - JPA example with drop downs anywhere ?
> > > > > What is the paved way to persisting classes with sequential ids ?
>
> > > > > Thanks in advance.
>
> > > > > cscsaba
>
> > > > > (Since there many case when we have to upload these entities from
> > file with
> > > > > their own ids  - Country, City and many more)
>
> > > > >  --
> > > > > 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
> > > > > google-appengine-j...@googlegroups.com.
> > > > > To unsubscribe from this group, send email to
> > > > > google-appengine-java+unsubscr...@googlegroups.com
> > 
>
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/google-appengine-java?hl=en.
>
> > > > --
> > > > Ikai Lan
> > > > Developer Programs Engineer, Google App Engine
> > > > Blog:http://googleappengine.blogspot.com
> > > > Twitter:http://twitter.com/app_engine
> > > > Reddit:http://www.reddit.com/r/appengine
>
> > --
> > 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
> > google-appengine-j...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengine-java+unsubscr...@googlegroups.com
> > .
> > 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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Re: Problem persist JDO- one to many

2010-07-11 Thread Prashant
you need to create a new method in Torneo which will detach collections
field. Now you just need to call this function with PersistenceManager as
argument.

public Torneo devolverTorneo(Long idTorneo) {

 Torneo b = pm.getObjectById(Torneo.class, idTorneo);

   b.detachFields(pm);
   b=pm.detachCopy(b);
   pm.close();

 return b;
 //The method return the object for update

}


public class Torneo implements Serializable{


public void detachFields(PersistenceManager pm) {

 pm.detachCopyAll(equiposTorneo);

}


}

-- 
Prashant
www.claymus.com

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Why are filters not used on first access?

2010-07-11 Thread Shawn Brown
 Hi,

> Please read the second paragraph of:
> http://code.google.com/appengine/docs/java/gettingstarted/staticfiles.html
> You'll need to exclude your files from  in appengine-web.xml
> if you are relying on a custom filter for authentication purposes.

Thanks.

IMHO it should be documented here
http://code.google.com/appengine/docs/java/config/webxml.html#Filters

Anyway, thanks!

Shawn

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] each entity as separate entity group

2010-07-11 Thread asianCoolz
i did my research and found that requirement to write entity(table) in
denormalized form. In this case, one entity(table) will not be related
to another entity(table) [no join] .


1. Is there any limit of number of entity group we can create?
2. what is the 'write speed per second' if i do it this way? since
everything is in seperate entity (root). i'm sure query(select) will
be required more steps this way
3. Is this best practice for using datastore at the moment?

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] jdo and pm.close()?

2010-07-11 Thread Ronmell Fuentes
Hi Andres.
when you build a PersistenceManager, the instance must be done just once
during the call in your method, class, etc., so, if you want to continue
with doing more tasks with it, it's ok. just when the call to your manager
class is ended then you can delete or end the manager, otherwise you can
keep using it. Remember the process of building the manager is done just
once in your whole app, but the instances can be many.

Rgds.

R

2010/7/11 Andrés Cerezo 

> If i want to execute this source code without errors, I have to delete the
> first pm.close(); Anyone knows why?
>
>
>   final Date date = new Date();
> EmployeeData employee = new  EmployeeData("John", "Doe", date);
>
>   PersistenceManager pm = PMF.get().getPersistenceManager();
>
>   final Long id = pm.makePersistent(employee).getId();
>
>   // From a different persistence manager, look up the // object
>
>   employee = pm.getObjectById(EmployeeData.class, id);
>   assertEquals(employee.getFirstName(), "John");
>   assertEquals(employee.getLastName(), "Doe");
>
>   pm.close();
>
>  pm = PMF.get().getPersistenceManager(); */
>
>
>   EmployeeData employee2 = new EmployeeData("John2", "Doe2", date);
>
>   final Long id2 = pm.makePersistent(employee2).getId();
>
>   // From a different persistence manager, look up the // object
>
>   employee2 = pm.getObjectById(EmployeeData.class, id2);
>   assertEquals(employee2.getFirstName(), "John");
>   assertEquals(employee2.getLastName(), "Doe");
>
>   pm.close();
>
> Thanks.
>
> --
> 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
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>



-- 
ausencia de evidencia  ≠  evidencia de ausencia
http://culturainteractiva.blogspot.com/

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Why are filters not used on first access?

2010-07-11 Thread Don Schwarz
Please read the second paragraph of:

http://code.google.com/appengine/docs/java/gettingstarted/staticfiles.html

You'll need to exclude your files from  in appengine-web.xml
if you are relying on a custom filter for authentication purposes.

On Mon, Jul 12, 2010 at 3:27 AM, Shawn Brown wrote:

> Hi,
>
> I have a filter set for all requests.  Yet the first request to GAE
> seems to bypass the filter.  Why/How could that be?
>
> I do have a welcome file set
>
> MyAppGAE.html
>
> but shouldn't that get called by the following filter
>
> 
>   AuthenticationFilter
>   /*
> 
>
> Using a url like (running locally)
> http://127.0.0.1:/MyAppGAE.html?gwt.codesvr=127.0.0.1:9997#login,
> why does the filter get bypassed on first access.  Subsequest rpc
> calls to the app do trigger the filter but I'm worried that before I
> can authenticate the user, they have a chance to make an rpc call.
> It's a huge potential security hole.
>
> If it's the browser caching something, then when I change the welcome
> page MyAppGAE.html, I would expect the filter to be applied when the
> user gets the new page.  I can see the new page but still don't see
> the filter applied.
>
> What am I not understanding???
>
> Shawn
>
> --
> 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
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com
> .
> 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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Why are filters not used on first access?

2010-07-11 Thread Shawn Brown
Hi,

I have a filter set for all requests.  Yet the first request to GAE
seems to bypass the filter.  Why/How could that be?

I do have a welcome file set

MyAppGAE.html

but shouldn't that get called by the following filter


   AuthenticationFilter
   /*


Using a url like (running locally)
http://127.0.0.1:/MyAppGAE.html?gwt.codesvr=127.0.0.1:9997#login,
why does the filter get bypassed on first access.  Subsequest rpc
calls to the app do trigger the filter but I'm worried that before I
can authenticate the user, they have a chance to make an rpc call.
It's a huge potential security hole.

If it's the browser caching something, then when I change the welcome
page MyAppGAE.html, I would expect the filter to be applied when the
user gets the new page.  I can see the new page but still don't see
the filter applied.

What am I not understanding???

Shawn

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] jdo and pm.close()?

2010-07-11 Thread Andrés Cerezo
If i want to execute this source code without errors, I have to delete the
first pm.close(); Anyone knows why?


  final Date date = new Date();
EmployeeData employee = new  EmployeeData("John", "Doe", date);

  PersistenceManager pm = PMF.get().getPersistenceManager();

  final Long id = pm.makePersistent(employee).getId();

  // From a different persistence manager, look up the // object

  employee = pm.getObjectById(EmployeeData.class, id);
  assertEquals(employee.getFirstName(), "John");
  assertEquals(employee.getLastName(), "Doe");

  pm.close();

 pm = PMF.get().getPersistenceManager(); */


  EmployeeData employee2 = new EmployeeData("John2", "Doe2", date);

  final Long id2 = pm.makePersistent(employee2).getId();

  // From a different persistence manager, look up the // object

  employee2 = pm.getObjectById(EmployeeData.class, id2);
  assertEquals(employee2.getFirstName(), "John");
  assertEquals(employee2.getLastName(), "Doe");

  pm.close();

Thanks.

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Sending mail in transaction

2010-07-11 Thread Marcus Brody
I know :( I just thought there maybe be some trick with special case :
Sending Mail.
Good is it forces to think :)

On Jul 11, 11:57 pm, dflorey  wrote:
> AFAIK there is no (simple) way to turn requests with undefined result
> into idempotent tasks. I've been struggling to execute gdata insert
> requests in a transaction as they may return with a timeout.
> It would be very nice if google would provide the standard services in
> an idempotent manner.
>
> On 10 Jul., 18:43, Marcus Brody  wrote:
>
> > Hello,
>
> > I would like to ask, if there is some way how to send mail only in
> > case that some db transaction will be successful.
> > I am not very experienced with gae, but I did study it now for about 2
> > weeks.
>
> > Desired output:
>
> >           1) prepare email
> >           2) db transaction.begin()
> >           3) do some db operation
> >           4) bind sending mail with current transaction (similar to
> > how can you can attach Task to queue)
> >           5) db transaction.commit()
>
> > I am aware that I can queue mail sending task to task queue, but i
> > cannot find the way how to do that mail sending task Idempotent
> > without (i think) complicated locking mechanism .
> > Most simple solution would be to put mail sending task to task queue,
> > but this means mail could be send twice in some rare situation. (this
> > is maybe not that bad but if there is some way how to avoid it, I
> > would like to know)
>
> > Thank you,
>
> > Marcus
>
>

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] The important annotation of one to many

2010-07-11 Thread lisandrodc
Hi! I have an important javadoc annotations for one-to many relations.
In the class that contains the collection:

@Persistent(mappedBy = "torneo", defaultFetchGroup = "true")
private List equiposTorneo;

If we do not place defaultFetchGroup = "true", when  we want to
recover the object that contains the collection, for example with
method getObjectById(), this collection is null. But with
defaultFetchGroup = "true", this does not happen. This it does not
clarify the documentation of google or at least I did not find it.
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Sending mail in transaction

2010-07-11 Thread dflorey
AFAIK there is no (simple) way to turn requests with undefined result
into idempotent tasks. I've been struggling to execute gdata insert
requests in a transaction as they may return with a timeout.
It would be very nice if google would provide the standard services in
an idempotent manner.

On 10 Jul., 18:43, Marcus Brody  wrote:
> Hello,
>
> I would like to ask, if there is some way how to send mail only in
> case that some db transaction will be successful.
> I am not very experienced with gae, but I did study it now for about 2
> weeks.
>
> Desired output:
>
>           1) prepare email
>           2) db transaction.begin()
>           3) do some db operation
>           4) bind sending mail with current transaction (similar to
> how can you can attach Task to queue)
>           5) db transaction.commit()
>
> I am aware that I can queue mail sending task to task queue, but i
> cannot find the way how to do that mail sending task Idempotent
> without (i think) complicated locking mechanism .
> Most simple solution would be to put mail sending task to task queue,
> but this means mail could be send twice in some rare situation. (this
> is maybe not that bad but if there is some way how to avoid it, I
> would like to know)
>
> Thank you,
>
> Marcus

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Getting oauth twitter to work, using dyuproject

2010-07-11 Thread Mark
Hi,

I just found dyuproject by David Yu:

http://dyuproject.appspot.com/oauth
http://code.google.com/p/dyuproject/

which is great, very easy to integrate and get oauth working. The demo
project at appspot shows twitter working, but I cannot find the
corresponding source code in the repository:

 
http://code.google.com/p/dyuproject/source/browse/#svn/trunk/modules/demos/oauth-consumer-servlet/src/main/java/com/dyuproject/demos/oauthconsumer

am I not looking in the right place?

Thanks

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Problem persist JDO- one to many

2010-07-11 Thread lisandrodc
Thanks Prashant, but not understand...That would be to do detach b
including all of its collections of child entities?Example of code?
The objects "Equipo" is created in my database, but when get for
Torneo b = pm.getObjectById(Torneo.class, idTorneo); the
b.getEquiposTorneo that is a collection is null. The name for example
is getting,
but not the collection...I have a singleton pattern for the Persistent
manager for all
the system.If I close it,lose the functionality.
Regards

On 11 jul, 15:04, Prashant  wrote:
> before returning b (Torneo), if you are closing PersistentManger you must
> detach b including all of its collections of child entities.
>
> --
> Prashantwww.claymus.com

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Distributed Transactions

2010-07-11 Thread David Sowerby
There is always a good deal of debate in this group about transactions
- but does anyone know what the status is of the design presented by
Daniel Wilkerson at Google I/O 2009?  There don't seem to have been
any recent updates to either of the following:

Design explanation at http://danielwilkerson.com/dist-trans-gae.html
code (only) posted at http://code.google.com/p/tapioca-orm/

The video of the presentation is at
http://code.google.com/events/io/2009/sessions/DesignDistributedTransactionLayerAppEngine.html
and seemed great work which could transform the use of app engine.

Has it just proved too difficult to implement on the Google
infrastructure?

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Problem persist JDO- one to many

2010-07-11 Thread Prashant
before returning b (Torneo), if you are closing PersistentManger you must
detach b including all of its collections of child entities.


-- 
Prashant
www.claymus.com

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Problem persist JDO- one to many

2010-07-11 Thread lisandrodc
Hi! I have a problem for persist a relation one to many.
The problem is that when update the object "Torneo" with a new
"Equipo", at get for
the method Torneo b = pm.getObjectById(Torneo.class, idTorneo); the
b.getEquiposTorneo that is a collection is null.On having added a
"Equipo" to "Torneo", stored the objects "Equipo " in the database,
but everything returns to the reuperarlo except the collections.
The Code:
The "Torneo" class:
public class Torneo implements Serializable{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
private String nombre;
@Persistent
private String imagen;
@Persistent
private Date fechaInicio;
@Persistent
private Date fechaFin;
@Persistent
private List fechasTorneo;
@Persistent
private List usuarios;
 @Persistent
private List equiposTorneo;
//   with(getter and setter)
.




The Equipo class:
public class Equipo implements Serializable{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key id;
@Persistent
private String nombre;
@Persistent
private String imagen;
@Persistent
private String desc;
@Persistent
private Torneo torneo;

.
}
 Add an "Equipo" class to a "Torneo" class:

public void crearTorneo(String nombre, Date fechaInicio, Date
fechaFin,
String imagen) {
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Torneo torneo = new Torneo(nombre, imagen, fechaInicio, 
fechaFin);
System.out.println("nombre " + nombre);
pm.makePersistent(torneo);
 // Here I see for the point that the collection
is empty not void (because the set in the constructor)
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
}

}


public Torneo devolverTorneo(Long idTorneo) {



Torneo b = pm.getObjectById(Torneo.class, idTorneo);

   return b;
   //The method return the object for update


}
Regards!

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Breaking change in data store?

2010-07-11 Thread Marcus Brody
Hello Marc,

this maybe be blind shot, but I think i faced similar problem,
problem is I think following (although my primary key was encoded
string I believe its the same issue)

Description of problem:
You have persisted some of you entities WITHOUT setting your
primary key (you just let it NULL),
so system generated Long.
Later you do query or something and access Key property getName()
but since given key has id=Long it fails

So basically the exception description:
The primary key for mymodel.JarData is an unencoded string but the key
of the corresponding entity in the datastore does not have a name

is correct

Solution:
Make sure that that you always set primary key prior to saving, or if
you want to have more flexibility,
and be able to have
1)system generated ID and
2)your app generated ID

make sure you check if its Long of Unencoded String by converting
primary key to Key object and then
make checks before accessing getName() or getID() (only 1 can be set)

If I am right this has nothing to do with downtime issue.
Hope this helps you,

Marcus

On Jul 8, 11:39 am, Marc Guillemot  wrote:
> Hi,
>
> yesterday my application worked just fine. Today data isn't reachable
> with a simple query anymore (data is here, I can find it through the
> Data Viewer).
>
> Here is the exception thrown:
> 
> Uncaught exception from servlet
> The primary key for mymodel.JarData is an unencoded string but the key
> of the corresponding entity in the datastore does not have a name.  You
> may want to either change the primary key to be an encoded string (add
> the "gae.encoded-pk" extension), change the primary key to be of type
> com.google.appengine.api.datastore.Key, or, if you're certain that this
> class will never have a parent, change the primary key to be of type Long.
> org.datanucleus.store.appengine.FatalNucleusUserException: The primary
> key for mymodel.JarData is an unencoded string but the key of the
> corresponding entity in the datastore does not have a name.  You may
> want to either change the primary key to be an encoded string (add the
> "gae.encoded-pk" extension), change the primary key to be of type
> com.google.appengine.api.datastore.Key, or, if you're certain that this
> class will never have a parent, change the primary key to be of type Long.
>         at
> org.datanucleus.store.appengine.DatastoreFieldManager.fetchStringPKField(DatastoreFieldManager.java:246)
>         at
> org.datanucleus.store.appengine.DatastoreFieldManager.fetchStringField(DatastoreFieldManager.java:192)
>         at
> org.datanucleus.state.AbstractStateManager.replacingStringField(AbstractStateManager.java:1180)
> 
> 
>
> My question: how can it happen, that changes in DataStore have such
> breaking consequences? And how often will it happen?
>
> Cheers,
> Marc.
> --
> Blog:http://mguillem.wordpress.com

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] how should I design my data model for following scenario

2010-07-11 Thread Miroslav Genov


I suggest you to store date value as an string value and to search over 
the string value. For example if user selects a date 2010-10-20, your 
code should translate it into a string value
"20101020" before it saves it into the database. After this value is 
stored as a string, you can use it in the queries.


For example you could define your search index as follow:

private String invoiceDateIndex;
private List invoiceItemIndex;


Query searchQuery = new Query("InvoiceItemIndex");
searchQuery.addFilter("invoiceDateIndex", Query.FilterOperator.EQUAL, 
requestedInvoiceDate);
searchQuery.addFilter("invoiceItemIndex", Query.FilterOperator.EQUAL, 
requestedItemValue);



Hope that this will help you find out how to query over all items.


Regards,
 Miroslav



On 07/11/2010 01:58 PM, Parvez wrote:

I want retrieve invoice numbers depending upon items e.g.

InvoiceNoItem  InvoiceDate

10  item_a
11  item_a
11  item_b
11  item_z
12  item_a
12  item_c
12  item_x
13  item_a
13  item_x

User can search on item(s) and can also include period (invoice date)
as part of search.
Initially, I tried using list property for Item, it worked but then it
failed once more than 6, 7 items included in query along with date
i.e. "Too many indexed properties for entity.." [:-) then I found out
that I can not delete index in java, using java sdk 1.3.5, it works
locally, but does not work when application uploaded]

In above example if user query for "item_a" and  "item_b" then I
should only get invoice number 11.
Any suggestion how can I achieve this?
Thanks.

   


--
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: how should I design my data model for following scenario

2010-07-11 Thread Robert Lancer
I dont fully understand the problem, but you might want to look into
using the IN filter option that can take a list of items and return
the associated entities, if the list is small enough you can cook up
the set operations in memory.



On Jul 11, 6:58 am, Parvez  wrote:
> I want retrieve invoice numbers depending upon items e.g.
>
> InvoiceNo        Item          InvoiceDate
>
> 10      item_a
> 11      item_a
> 11      item_b
> 11      item_z
> 12      item_a
> 12      item_c
> 12      item_x
> 13      item_a
> 13      item_x
>
> User can search on item(s) and can also include period (invoice date)
> as part of search.
> Initially, I tried using list property for Item, it worked but then it
> failed once more than 6, 7 items included in query along with date
> i.e. "Too many indexed properties for entity.." [:-) then I found out
> that I can not delete index in java, using java sdk 1.3.5, it works
> locally, but does not work when application uploaded]
>
> In above example if user query for "item_a" and  "item_b" then I
> should only get invoice number 11.
> Any suggestion how can I achieve this?
> Thanks.

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] how should I design my data model for following scenario

2010-07-11 Thread Parvez
I want retrieve invoice numbers depending upon items e.g.

InvoiceNoItem  InvoiceDate

10  item_a
11  item_a
11  item_b
11  item_z
12  item_a
12  item_c
12  item_x
13  item_a
13  item_x

User can search on item(s) and can also include period (invoice date)
as part of search.
Initially, I tried using list property for Item, it worked but then it
failed once more than 6, 7 items included in query along with date
i.e. "Too many indexed properties for entity.." [:-) then I found out
that I can not delete index in java, using java sdk 1.3.5, it works
locally, but does not work when application uploaded]

In above example if user query for "item_a" and  "item_b" then I
should only get invoice number 11.
Any suggestion how can I achieve this?
Thanks.

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] GAE static-files Cache-Control=private and caching non-static servlets web.xml expiration

2010-07-11 Thread Marc Hacker
I tried







but in fact I see my css file being served with header  Cache-
Control=private so not cached!  Any ideas?

Also how to I distinguish
(a) cache for 31days unless modified; from
(b) cache for 31days without even checking if-modified each time.

Finally I have some non-static files - servlets - which could be
safely cached even if modified (for example autocomplete data for a
search box does not always have to be up-to-the-second). How can I get
servlet content to be cached.

I tried setting a header max-age=3600 from inside the servlet but the
browser ignores it and always requests a fresh copy. Any ideas please?

Thanks

Marc.

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.