/** * Return a named EbeanServer that is typically different to the default server. * <p> * If you are using multiple databases then each database has a name and maps to a single * EbeanServer. You can use this method to get an EbeanServer for another database. * * @param server The name of the EbeanServer. If this is null then the default EbeanServer is returned. */ public static EbeanServer db(String server) { return Ebean.getServer(server); }
@Override public int execute() { if (server != null) { if (batched) { server.executeBatch(this, transaction); return -1; } return server.execute(this); } else { // Hopefully this doesn't catch anyone out... return Ebean.execute(this); } }
private static SpiEbeanServer server() { return (SpiEbeanServer) Ebean.getDefaultServer(); } }
/** * Equal To - property equal to the given value. */ public static Expression eq(String propertyName, Object value) { return Ebean.getExpressionFactory().eq(propertyName, value); }
/** * Return the current transaction (of the default server) or null if there is * no current transaction in scope. * <p> * This is the same as <code>Ebean.currentTransaction()</code> * </p> * <p> * This returns the current transaction for the 'default server'. If you are using * multiple EbeanServer's then use {@link EbeanServer#currentTransaction()}. * </p> * * @see Ebean#currentTransaction() * @see EbeanServer#currentTransaction() */ static Transaction current() { return Ebean.currentTransaction(); }
/** * Return an object relational query for finding a List, Set, Map or single entity bean. * * @return the Query. */ public static <T> Query<T> query(Class<T> entityType) { Assert.notNull(entityType, "entityType must not null"); return Ebean.find(entityType); }
public CompletionStage<Result> call(final Context ctx) { return Ebean.executeCall(() -> delegate.call(ctx)); } }
private synchronized void loadAll() { log.info("loading test data ----------------------------------------------"); runOnce = true; if (Country.find.query().findCount() > 0) { return; } try (Transaction transaction = Ebean.beginTransaction()) { try { deleteAll(); insertReference(); insertTestCustAndOrders(); transaction.commit(); } catch (Throwable e) { e.printStackTrace(); log.error("Error seeding", e); } } }
private static Customer createCustomer(String name, String shippingStreet, String billingStreet, int contactSuffix) { Customer c = new Customer(name); if (contactSuffix > 0) { c.addContact(new Contact("Jim" + contactSuffix, "Cricket")); c.addContact(new Contact("Fred" + contactSuffix, "Blue")); c.addContact(new Contact("Bugs" + contactSuffix, "Bunny")); } if (shippingStreet != null) { Address shippingAddr = new Address(); shippingAddr.setLine1(shippingStreet); shippingAddr.setLine2("Sandringham"); shippingAddr.setCity("Auckland"); shippingAddr.setCountry(Country.find.ref("NZ")); c.setShippingAddress(shippingAddr); } if (billingStreet != null) { Address billingAddr = new Address(); billingAddr.setLine1(billingStreet); billingAddr.setLine2("St Lukes"); billingAddr.setCity("Auckland"); billingAddr.setCountry(Ebean.getReference(Country.class, "NZ")); c.setBillingAddress(billingAddr); } return c; }
/** * Less Than or Equal to - property less than or equal to the given value. */ public static Expression le(String propertyName, Object value) { return Ebean.getExpressionFactory().le(propertyName, value); }
/** * The batch will be flushing automatically but you can use this to explicitly * flush the batch if you like. * <p> * Flushing occurs automatically when: * </p> * <ul> * <li>the batch size is reached</li> * <li>A query is executed on the same transaction</li> * <li>UpdateSql or CallableSql are mixed with bean save and delete</li> * <li>Transaction commit occurs</li> * <li>A getter method is called on a batched bean</li> * </ul> */ public static void flush() { currentTransaction().flush(); }
/** * Return an object relational query for finding a List, Set, Map or single entity bean. * * @return the Query. */ public static <T> Query<T> query(Class<T> entityType) { Assert.notNull(entityType, "entityType must not null"); return Ebean.find(entityType); }
/** * Return the underlying 'default' EbeanServer. * <p> * This provides full access to the API such as explicit transaction demarcation etc. */ public EbeanServer db() { return Ebean.getServer(serverName); }
/** * Case insensitive Like - property like value where the value contains the * SQL wild card characters % (percentage) and _ (underscore). Typically uses * a lower() function to make the expression case insensitive. */ public static Expression ilike(String propertyName, String value) { return Ebean.getExpressionFactory().ilike(propertyName, value); }
return Ebean.getDefaultServer();
@Override public int execute() { if (server != null) { if (batched) { server.executeBatch(this, transaction); return -1; } return server.execute(this); } else { // Hopefully this doesn't catch anyone out... return Ebean.execute(this); } }
/** * Return the current transaction (of the default server) or null if there is * no current transaction in scope. * <p> * This is the same as <code>Ebean.currentTransaction()</code> * </p> * <p> * This returns the current transaction for the 'default server'. If you are using * multiple EbeanServer's then use {@link EbeanServer#currentTransaction()}. * </p> * * @see Ebean#currentTransaction() * @see EbeanServer#currentTransaction() */ static Transaction current() { return Ebean.currentTransaction(); }
/** * Return typically a different EbeanServer to the default. * <p> * This is equivalent to {@link Ebean#getServer(String)} * * @param server The name of the EbeanServer. If this is null then the default EbeanServer is * returned. */ public EbeanServer db(String server) { return Ebean.getServer(server); }
/** * Id Equal to - ID property is equal to the value. */ public static Expression idEq(Object value) { return Ebean.getExpressionFactory().idEq(value); }
/** * Set default server and platform if necessary. */ private void setDefaults() { if (server == null) { setServer(Ebean.getDefaultServer()); } if (vanillaPlatform || databasePlatform == null) { // not explicitly set so use the platform of the server databasePlatform = server.getDatabasePlatform(); } if (migrationConfig != null) { if (strictMode != null) { migrationConfig.setStrictMode(strictMode); } if (applyPrefix != null) { migrationConfig.setApplyPrefix(applyPrefix); } if (header != null) { migrationConfig.setDdlHeader(header); } } }