Package io.ebean

Enum PersistenceContextScope

    • Enum Constant Detail

      • TRANSACTION

        public static final PersistenceContextScope TRANSACTION
        PersistenceContext is scoped to the transaction.

        If a transaction spans 2 or more queries that fetch the same bean in terms of same type and same Id value then they share the same bean instance.

        You may want to change to use QUERY scope when you want a query executing in a transaction to effectively ignore beans that have already been loaded (by other queries in the same transaction) and instead get a 'fresh copy' of the bean.

      • QUERY

        public static final PersistenceContextScope QUERY
        PersistenceContext is scoped to the query.

        This means that for this query running in an existing transaction then it will effectively ignore any beans that have already been queried/loaded by prior queries in the same transaction.

        You may use QUERY scope on a query that is executed in a transaction and you want to get a 'fresh copy' of the bean.

    • Method Detail

      • values

        public static PersistenceContextScope[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (PersistenceContextScope c : PersistenceContextScope.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static PersistenceContextScope valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null