I'm trying to add a new root entity with the following code:

```
    try {
        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
        Key eventKey = datastore.allocateIds("Event", 1).getStart();
        String keyString = KeyFactory.keyToString(eventKey);

        //TransactionOptions options = TransactionOptions.Builder.withXG(true);
        Transaction txn = datastore.beginTransaction();
        Entity eventEntity = new Entity("Event", keyString);

        datastore.put(eventEntity);

        txn.commit();
    } catch (Exception e) {
        log.log(Level.SEVERE, e.getMessage(), e);
        throw new InternalServerErrorException(e);
    }

```

It's a simple transactional datastore insert that according to the [documents](https://developers.google.com/appengine/docs/python/datastore/transactions#Python_What_can_be_done_in_a_transaction) suppose to work -

> 
> each root entity belongs to a separate entity group, so a single transaction cannot create or operate on more than one root entity unless it is an XG transaction
> 
> 
> 

My 'Event' entity doesnt have any ancestor And i'm only handling it inside the transaction. But for some reason i get the following exception :

> 
> java.lang.IllegalArgumentException: cross-group transaction need to be explicitly specified, see TransactionOptions.Builder.withXGfound both Element {
>  type: "Event"
>  id: 4
>  }
>  and Element {
>  type: "Event"
>  name: "ahBldmVudHNmaW5kZXIyMDEzcgsLEgVFdmVudBgEDA"
>  }
> 
> 
> 

Any idea whats wrong here ?