Package org.hibernate

Examples of org.hibernate.FlushMode


            ErrorManager.lookup().notifyError(t, true);
        }
    }

    protected final void executeFragment(HibernateTxFragment fragment) throws Exception {
        FlushMode flushMode = session.getFlushMode();
        boolean flushChanged = false;
        try {
            // Change the current fragment.
            fragment.parentFragment = currentFragment;
            currentFragment = fragment;
View Full Code Here


  public static void bindQuery(org.hibernate.annotations.NamedQuery queryAnn, Mappings mappings) {
    if ( queryAnn == null ) return;
    if ( BinderHelper.isEmptyAnnotationValue( 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.name(),
        queryAnn.query(),
View Full Code Here

      LOG.debugf( "Binding named query: %s => %s", query.getName(), query.getQueryString() );
    }
  }

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

  public FlushModeType getFlushMode() {
    if ( jpaFlushMode != null ) {
      return jpaFlushMode;
    }
    final FlushMode hibernateFlushMode = session.getFlushMode();
    if ( FlushMode.AUTO == hibernateFlushMode ) {
      return FlushModeType.AUTO;
    }
    else if ( FlushMode.COMMIT == hibernateFlushMode ) {
      return FlushModeType.COMMIT;
View Full Code Here

    public WorkspaceImpl[] getWorkspaces() {
        final List<WorkspaceImpl> workspaces = new ArrayList<WorkspaceImpl>();

        HibernateTxFragment txFragment = new HibernateTxFragment() {
            protected void txFragment(Session session) throws Exception {
                FlushMode oldFlushMode = session.getFlushMode();
                session.setFlushMode(FlushMode.NEVER);
                Query q = session.createQuery(" from " + WorkspaceImpl.class.getName());
                q.setCacheable(true);
                workspaces.addAll(q.list());
                session.setFlushMode(oldFlushMode);
View Full Code Here

    public Workspace getWorkspaceByUrl(final String url) throws Exception {
        final Workspace[] workspace = new Workspace[1];
        new HibernateTxFragment() {
            protected void txFragment(Session session) throws Exception {
                FlushMode oldFlushMode = session.getFlushMode();
                session.setFlushMode(FlushMode.NEVER);
                Query q = session.createQuery(" from " + WorkspaceImpl.class.getName() + " p where p.friendlyUrl = :url");
                q.setString("url", url);
                q.setCacheable(true);
                List l = q.list();
View Full Code Here

    protected void loadDbElements() throws Exception {
        elements = new Vector();

        HibernateTxFragment txFragment = new HibernateTxFragment() {
            protected void txFragment(Session session) throws Exception {
                FlushMode oldFlushMode = session.getFlushMode();
                session.setFlushMode(FlushMode.NEVER);
                List dbItems = session.createQuery("from " + classToHandle.getName() + " as element").list();
                for (int i = 0; i < dbItems.size(); i++) {
                    GraphicElement element = (GraphicElement) dbItems.get(i);
                    //element.deploy();
View Full Code Here

        if (dbid == null) return null;

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

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

        final List<Section> childSections = new ArrayList<Section>();

        try {
            new HibernateTxFragment() {
            protected void txFragment(Session session) throws Exception {
                FlushMode oldFlushMode = session.getFlushMode();
                session.setFlushMode(FlushMode.NEVER);

                StringBuffer hql = new StringBuffer("from ");
                hql.append(Section.class.getName()).append(" as section where section.workspace=:workspace");
                if (sectionId == null) hql.append(" and section.parentSectionId is null");
View Full Code Here

    public int getSectionsCount() {
        try {
            final int[] size = new int[1];
            new HibernateTxFragment() {
                protected void txFragment(Session session) throws Exception {
                    FlushMode oldFlushMode = session.getFlushMode();
                    session.setFlushMode(FlushMode.NEVER);
                    Query query = session.createQuery("from " + Section.class.getName() + " as section " +
                            "where section.workspace=:workspace");

                    query.setParameter("workspace", WorkspaceImpl.this);
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.