@ SuppressWarnings ( "unchecked" ) public < E > List < E > insert ( List < E > entities ) { if ( entities == null || entities . isEmpty ( ) ) { return new ArrayList <> ( ) ; } try { entityManager . executeEntityListeners ( CallbackType . PRE_INSERT , entities ) ; FullEntity < ? > [ ] nativeEntities = toNativeFullEntities ( entities , entityManager , Intent . INSERT ) ; Class < ? > entityClass = entities . get ( 0 ) . getClass ( ) ; List < Entity > insertedNativeEntities = nativeWriter . add ( nativeEntities ) ; List < E > insertedEntities = ( List < E > ) toEntities ( entityClass , insertedNativeEntities ) ; entityManager . executeEntityListeners ( CallbackType . POST_INSERT , insertedEntities ) ; return insertedEntities ; } catch ( DatastoreException exp ) { throw DatastoreUtils . wrap ( exp ) ; } }
Inserts the given list of entities into the Cloud Datastore .