Package org.hibernate

Examples of org.hibernate.FlushMode


    if ( queryAnn == null ) return;
    if ( BinderHelper.isDefault( queryAnn.name() ) ) {
      throw new AnnotationException( "A named query must have a name when used in class or package level" );
    }

    FlushMode flushMode;
    flushMode = getFlushMode( queryAnn.flushMode() );

    NamedQueryDefinition query = new NamedQueryDefinition(
        queryAnn.query(),
        queryAnn.cacheable(),
View Full Code Here


    mappings.addQuery( queryAnn.name(), query );
    if ( log.isInfoEnabled() ) log.info( "Binding named query: " + queryAnn.name() + " => " + queryAnn.query() );
  }

  private static FlushMode getFlushMode(FlushModeType flushModeType) {
    FlushMode flushMode;
    switch ( flushModeType ) {
      case ALWAYS:
        flushMode = FlushMode.ALWAYS;
        break;
      case AUTO:
View Full Code Here

    public HTMLText load(final PanelInstance instance) {
        final List<HTMLText> results = new ArrayList<HTMLText>();
        try {
            new HibernateTxFragment() {
            protected void txFragment(Session session) throws Exception {
                FlushMode oldFlushMode = session.getFlushMode();
                session.setFlushMode(FlushMode.NEVER);
                Query query = session.createQuery(" from " + HTMLText.class.getName() + " as text where text.panelInstance = :instance");
                query.setParameter("instance", instance);
                query.setCacheable(true);
                results.addAll(query.list());
View Full Code Here

        final HTMLText[] textArray = new HTMLText[1];
        try {
            new HibernateTxFragment() {
            protected void txFragment(Session session) throws Exception {
                log.debug("Getting text to duplicate for instance " + src.getDbid());
                FlushMode oldMode = session.getFlushMode();
                session.setFlushMode(FlushMode.COMMIT);//Avoids flushing, as we know the text was not modified in this transaction.
                textArray[0] = load(src);
                session.setFlushMode(oldMode);
                log.debug("Got text to duplicate for instance " + src.getDbid());
            }}.execute();
View Full Code Here

    public HTMLText load(final PanelInstance instance) {
        final List results = new ArrayList();
        try {
            new HibernateTxFragment() {
            protected void txFragment(Session session) throws Exception {
                FlushMode oldFlushMode = session.getFlushMode();
                session.setFlushMode(FlushMode.NEVER);
                Query query = session.createQuery(" from " + HTMLText.class.getName() + " as text where text.panelInstance = :instance");
                query.setParameter("instance", instance);
                query.setCacheable(true);
                results.addAll(query.list());
View Full Code Here

        final HTMLText[] textArray = new HTMLText[1];
        try {
            new HibernateTxFragment() {
            protected void txFragment(Session session) throws Exception {
                log.debug("Getting text to duplicate for instance " + src.getDbid());
                FlushMode oldMode = session.getFlushMode();
                session.setFlushMode(FlushMode.COMMIT);//Avoids flushing, as we know the text was not modified in this transaction.
                textArray[0] = load(src);
                session.setFlushMode(oldMode);
                log.debug("Got text to duplicate for instance " + src.getDbid());
            }}.execute();
View Full Code Here

        final List result = new ArrayList();
        try {
            new HibernateTxFragment() {
            protected void txFragment(Session session) throws Exception {
                Query query = session.createQuery(" from " + DataSourceEntry.class.getName());
                FlushMode oldFlushMode = session.getFlushMode();
                session.setFlushMode(FlushMode.COMMIT);
                query.setCacheable(true);
                result.addAll(query.list());
                session.setFlushMode(oldFlushMode);
            }}.execute();
View Full Code Here

        if (name == null) return null;

        final List results = new ArrayList();
        new HibernateTxFragment() {
        protected void txFragment(Session session) throws Exception {
            FlushMode flushMode = session.getFlushMode();
            session.setFlushMode(FlushMode.COMMIT);

            StringBuffer sql = new StringBuffer();
            sql.append("select dse ");
            sql.append("from ").append(DataSourceEntry.class.getName()).append(" as dse ");
View Full Code Here

        final DataSourceEntry[] entryResult = new DataSourceEntry[] {null};
        try {
            new HibernateTxFragment() {
            protected void txFragment(Session session) throws Exception {
                Query query = session.createQuery(" from " + DataSourceEntry.class.getName() + " entry where entry.name = :entryName ");
                FlushMode oldFlushMode = session.getFlushMode();
                session.setFlushMode(FlushMode.COMMIT);
                query.setString("entryName", name);
                query.setCacheable(true);
                List results = query.list();
                if (results.size() == 1) entryResult[0] = (DataSourceEntry) results.get(0);
View Full Code Here

    Integer fetchSize = getInteger( hints, QueryHints.FETCH_SIZE, name );
    if ( fetchSize != null && fetchSize < 0 ) {
      fetchSize = null;
    }

    FlushMode flushMode = getFlushMode( hints, QueryHints.FLUSH_MODE, name );
    CacheMode cacheMode = getCacheMode( hints, QueryHints.CACHE_MODE, name );

    boolean readOnly = getBoolean( hints, QueryHints.READ_ONLY, name );

    String comment = getString( hints, QueryHints.COMMENT );
View Full Code Here

TOP

Related Classes of org.hibernate.FlushMode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.