List of usage examples for org.hibernate.type IntegerType IntegerType
public IntegerType()
From source file:com.amalto.core.storage.hibernate.StandardQueryHandler.java
License:Open Source License
@Override public StorageResults visit(GroupSize groupSize) { Projection groupSizeProjection = Projections.sqlGroupProjection( "count(this_." + Storage.METADATA_TASK_ID + ") as talend_group_size", //$NON-NLS-1$ //$NON-NLS-2$ "this_." + Storage.METADATA_TASK_ID, new String[] { "talend_group_size" }, //$NON-NLS-1$ //$NON-NLS-2$ new org.hibernate.type.Type[] { new IntegerType() }); projectionList.add(groupSizeProjection); return null;/*from w ww. j a va2 s .c o m*/ }
From source file:com.court.controller.GuarantorsFxmlController.java
private List<Member> getAvailableGuarantors() { Session session = HibernateUtil.getSessionFactory().openSession(); SQLQuery query = session//from w w w.j a v a2s . co m .createSQLQuery("SELECT\n" + " m.member_id AS memberId,\n" + " m.full_name AS fullName,\n" + " wb.branch_name AS workingOffice,\n" + " pb.branch_name AS payingOffice,\n" + " ml.member_loan_code AS loanCode,\n" + " ml.granted_date AS grantedDate,\n" + " ml.loan_amount AS loanAmount,\n" + " ml.loan_interest AS loanInterest,\n" + " ml.interest_per AS interestPer,\n" + " ml.interest_method AS interMethod,\n" + " ml.loan_duration AS loanDuration,\n" + " ml.duration_per AS lDurationPer,\n" + " ml.is_complete AS loanComplete\n" + "FROM\n" + " court_loan.branch wb\n" + "INNER JOIN\n" + " court_loan.member m\n" + "ON\n" + " (\n" + " wb.id = m.branch_id)\n" + "INNER JOIN\n" + " court_loan.branch pb\n" + "ON\n" + " (\n" + " m.pay_office_id = pb.id)\n" + "LEFT OUTER JOIN\n" + " court_loan.member_loan ml\n" + "ON\n" + " (\n" + " m.id = ml.member_id) ;") .addScalar("memberId", new StringType()).addScalar("fullName", new StringType()) .addScalar("workingOffice", new StringType()).addScalar("payingOffice", new StringType()) .addScalar("loanCode", new StringType()).addScalar("grantedDate", new DateType()) .addScalar("loanAmount", new DoubleType()).addScalar("loanInterest", new DoubleType()) .addScalar("interestPer", new StringType()).addScalar("interMethod", new StringType()) .addScalar("loanDuration", new IntegerType()).addScalar("lDurationPer", new StringType()) .addScalar("loanComplete", new BooleanType()); List<Object[]> rows = query.list(); List<Member> list = new ArrayList<>(); for (Object[] row : rows) { Member m = new Member(); m.setMemberId(row[0].toString()); m.setFullName(row[1].toString()); m.setBranch(new Branch(row[2].toString())); m.setPayOffice(new Branch(row[3].toString())); list.add(m); } session.close(); return list; }
From source file:com.mg.framework.service.HibernateListenerInjectorImpl.java
License:Open Source License
public void injectListeners(ObjectName objectName, Configuration configuration) throws DeploymentException { configuration.setListener("pre-insert", new PreInsertEventListener() { public boolean onPreInsert(PreInsertEvent event) { Object entity = event.getEntity(); if (!(entity instanceof PersistentObject)) return false; setGlobalAttributes((PersistentObject) entity, event.getState(), event.getPersister().getPropertyNames()); EntityInterceptorManagerLocator.locate().invokeOnPrePersistInterceptor((PersistentObject) entity); setUpdatedAttributes((PersistentObject) entity, event.getState(), event.getPersister()); return false; }// ww w. ja va 2s . co m }); configuration.setListener("post-insert", new PostInsertEventListener() { public void onPostInsert(PostInsertEvent event) { Object entity = event.getEntity(); if (!(entity instanceof PersistentObject)) return; EntityInterceptorManagerLocator.locate().invokeOnPostPersistInterceptor((PersistentObject) entity); } }); configuration.setListener("post-commit-insert", new PostInsertEventListener() { public void onPostInsert(PostInsertEvent event) { DatabaseAuditServiceLocator.locate().auditCreate(event); Object entity = event.getEntity(); if (!(entity instanceof PersistentObject)) return; EntityInterceptorManagerLocator.locate() .invokeOnPostCommitPersistInterceptor((PersistentObject) entity); } }); configuration.setListener("pre-delete", new PreDeleteEventListener() { public boolean onPreDelete(PreDeleteEvent event) { Object entity = event.getEntity(); if (!(entity instanceof PersistentObject)) return false; EntityInterceptorManagerLocator.locate().invokeOnPreRemoveInterceptor((PersistentObject) entity); return false; } }); configuration.setListener("post-delete", new PostDeleteEventListener() { public void onPostDelete(PostDeleteEvent event) { Object entity = event.getEntity(); if (!(entity instanceof PersistentObject)) return; EntityInterceptorManagerLocator.locate().invokeOnPostRemoveInterceptor((PersistentObject) entity); } }); configuration.setListener("post-commit-delete", new PostDeleteEventListener() { public void onPostDelete(PostDeleteEvent event) { DatabaseAuditServiceLocator.locate().auditRemove(event); Object entity = event.getEntity(); if (!(entity instanceof PersistentObject)) return; EntityInterceptorManagerLocator.locate() .invokeOnPostCommitRemoveInterceptor((PersistentObject) entity); } }); configuration.setListener("pre-update", new PreUpdateEventListener() { public boolean onPreUpdate(PreUpdateEvent event) { Object entity = event.getEntity(); if (!(entity instanceof PersistentObject)) return false; setGlobalAttributes((PersistentObject) entity, event.getState(), event.getPersister().getPropertyNames()); EntityInterceptorManagerLocator.locate().invokeOnPreUpdateInterceptor((PersistentObject) entity, createAttributesMap(event.getPersister().getPropertyNames(), event.getOldState())); setUpdatedAttributes((PersistentObject) entity, event.getState(), event.getPersister()); return false; } }); configuration.setListener("post-update", new PostUpdateEventListener() { public void onPostUpdate(PostUpdateEvent event) { Object entity = event.getEntity(); if (!(entity instanceof PersistentObject)) return; EntityInterceptorManagerLocator.locate().invokeOnPostUpdateInterceptor((PersistentObject) entity, createAttributesMap(event.getPersister().getPropertyNames(), event.getOldState())); setUpdatedAttributes((PersistentObject) entity, event.getState(), event.getPersister()); } }); configuration.setListener("post-commit-update", new PostUpdateEventListener() { public void onPostUpdate(PostUpdateEvent event) { DatabaseAuditServiceLocator.locate().auditModify(event); Object entity = event.getEntity(); if (!(entity instanceof PersistentObject)) return; EntityInterceptorManagerLocator.locate().invokeOnPostCommitUpdateInterceptor( (PersistentObject) entity, createAttributesMap(event.getPersister().getPropertyNames(), event.getOldState())); } }); configuration.setListener("post-load", new PostLoadEventListener() { public void onPostLoad(PostLoadEvent event) { Object entity = event.getEntity(); if (!(entity instanceof PersistentObject)) return; EntityInterceptorManagerLocator.locate().invokeOnPostLoadInterceptor((PersistentObject) entity); } }); //load workaround for http://issues.m-g.ru/bugzilla/show_bug.cgi?id=4413 try { File workaround = new File(ServerConfigLocator.locate().getServerHomeDir().getAbsolutePath() .concat("/mg-custom/patches/workaround_MBSA-4413.hbm.xml")); configuration.addFile(workaround); logger.info("Install patch MBSA-4413"); } catch (Exception e) { logger.error("Install patch MBSA-4413 failed", e); } //load workaround for http://issues.m-g.ru/bugzilla/show_bug.cgi?id=4866 try { HibernateMBean service = (HibernateMBean) MBeanProxyExt.create(HibernateMBean.class, objectName); String dialect = service.getDialect(); Class<?> dialectClass = ServerUtils.loadClass(dialect); //? ?? ? Firebird Interbase if (org.hibernate.dialect.InterbaseDialect.class.isAssignableFrom(dialectClass)) { File workaround = new File(ServerConfigLocator.locate().getServerHomeDir().getAbsolutePath() .concat("/mg-custom/patches/workaround_MBSA-4866.hbm.xml")); configuration.addFile(workaround); logger.info("Install patch MBSA-4866"); } } catch (Exception e) { logger.error("Install patch MBSA-4866 failed", e); } //setup global tenant filter Map<String, Object> paramTypes = new HashMap<String, Object>(); paramTypes.put("sysClientId", new IntegerType()); configuration.addFilterDefinition( new FilterDefinition("__mg_tenantFilter", "CLIENT_ID = :sysClientId", paramTypes)); }
From source file:com.minhafazenda.model.MfAuditoriaConfiguracaoModel.java
public List<MfAuditoriaView> findAUditoria(String nomeTabela) { Session objSession = this.objSessionFactory.openSession(); Query query = objSession//from w w w . j a va 2s . c om .createSQLQuery("SELECT id, usuario, chave_primaria_1, chave_primaria_2, acao, data_hora FROM " + nomeTabela + "_AUDITORIA_VIEW") .addScalar("id", new IntegerType()).addScalar("usuario", new StringType()) .addScalar("chave_primaria_1", new StringType()).addScalar("chave_primaria_2", new StringType()) .addScalar("acao", new StringType()).addScalar("data_hora", new DateType()) .setResultTransformer(Transformers.aliasToBean(MfAuditoriaView.class)); return query.list(); }
From source file:com.minhafazenda.model.MfAuditoriaViewItemModel.java
public List<MfAuditoriaViewItem> findByDescricao(Integer idAuditoria, String nomeTabela, String descricao) { Session objSession = this.objSessionFactory.openSession(); Query query = objSession// w ww . ja va 2 s .com .createSQLQuery(" SELECT id_auditoria_item, id, campo, valor_antigo, valor_novo " + " FROM " + nomeTabela + "_AUDITORIA_VIEW_item" + " WHERE id = " + idAuditoria + " AND (" + " campo like '%" + descricao + "%' OR " + " valor_antigo like '%" + descricao + "%' OR " + " valor_novo like '%" + descricao + "%')") .addScalar("id_auditoria_item", new IntegerType()).addScalar("id", new IntegerType()) .addScalar("campo", new StringType()).addScalar("valor_antigo", new StringType()) .addScalar("valor_novo", new StringType()) .setResultTransformer(Transformers.aliasToBean(MfAuditoriaViewItem.class)); return query.list(); }
From source file:com.minhafazenda.model.MfAuditoriaViewItemModel.java
public List<MfAuditoriaViewItem> findAUditoria(Integer idAuditoria, String nomeTabela) { Session objSession = this.objSessionFactory.openSession(); Query query = objSession// w w w .java 2 s .com .createSQLQuery("SELECT id_auditoria_item, id, campo, valor_antigo, valor_novo " + " FROM " + nomeTabela + "_AUDITORIA_VIEW_item" + " WHERE id = " + idAuditoria) .addScalar("id_auditoria_item", new IntegerType()).addScalar("id", new IntegerType()) .addScalar("campo", new StringType()).addScalar("valor_antigo", new StringType()) .addScalar("valor_novo", new StringType()) .setResultTransformer(Transformers.aliasToBean(MfAuditoriaViewItem.class)); return query.list(); }
From source file:com.minhafazenda.model.MfAuditoriaViewModel.java
public List<MfAuditoriaView> findByDescricao(String nomeTabela, String descricao) { Session objSession = this.objSessionFactory.openSession(); Query query = objSession//from w ww. j av a 2 s .c o m .createSQLQuery(" SELECT id, usuario, chave_primaria_1, chave_primaria_2, acao, data_hora " + " FROM " + nomeTabela + "_AUDITORIA_VIEW" + " WHERE usuario like '%" + descricao + "%' OR " + " chave_primaria_1 like '%" + descricao + "%' OR " + " chave_primaria_2 like '%" + descricao + "%' OR " + " acao like '%" + descricao + "%'") .addScalar("id", new IntegerType()).addScalar("usuario", new StringType()) .addScalar("chave_primaria_1", new StringType()).addScalar("chave_primaria_2", new StringType()) .addScalar("acao", new StringType()).addScalar("data_hora", new DateType()) .setResultTransformer(Transformers.aliasToBean(MfAuditoriaView.class)); return query.list(); }
From source file:com.minhafazenda.model.MfAuditoriaViewModel.java
public List<MfAuditoriaView> findAUditoria(String nomeTabela) { Session objSession = this.objSessionFactory.openSession(); Query query = objSession//from w ww .ja va 2s . c om .createSQLQuery("SELECT id, usuario, chave_primaria_1, chave_primaria_2, acao, data_hora FROM " + nomeTabela + "_AUDITORIA_VIEW") .addScalar("id", new IntegerType()).addScalar("usuario", new StringType()) .addScalar("chave_primaria_1", new StringType()).addScalar("chave_primaria_2", new StringType()) .addScalar("acao", new StringType()).addScalar("data_hora", new DateType()) .setResultTransformer(Transformers.aliasToBean(MfAuditoriaView.class)); // List<MfAuditoriaView> list = query.list(); // for (MfAuditoriaView list_ : list) { // System.out.print(list_.getAcao()); // System.out.print(list_.getChave_primaria_1()); // System.out.println(list_.getId()); // // } return query.list(); }
From source file:com.sapienter.jbilling.server.util.db.HibernateIdGenerator.java
License:Open Source License
/** * Constructs a new ID generator for the given segment. If the segment does * not exist in the sequence table, it will be created with the newly generated * id values starting from zero.// w ww . j a v a 2 s . c o m * * * @param segmentValue jbilling sequence name (value of the 'name' column) */ public HibernateIdGenerator(String segmentValue) { /* I consider this code to be a "horrific sin against nature and a total affront to the programming gods", but it's the only way to gain access to Hibernates IdentifierGenerator framework. Future versions of Hibernate may change the underlying implementation which will break this code. */ Properties configuration = new Properties(); configuration.setProperty(TableGenerator.TABLE_PARAM, "jbilling_seqs"); configuration.setProperty(TableGenerator.SEGMENT_COLUMN_PARAM, "name"); configuration.setProperty(TableGenerator.SEGMENT_VALUE_PARAM, segmentValue); configuration.setProperty(TableGenerator.VALUE_COLUMN_PARAM, "next_id"); configuration.setProperty(TableGenerator.INCREMENT_PARAM, "100"); sessionFactory = ((SessionFactory) Context.getBean(Context.Name.HIBERNATE_SESSION)); generator = IdentifierGeneratorFactory.create("org.hibernate.id.enhanced.TableGenerator", new IntegerType(), configuration, ((SessionFactoryImpl) sessionFactory).getDialect()); }
From source file:com.sisrni.dao.BecaDao.java
public List<PojoBeca> getBecas(Integer idBecaSearch) { String query = "SELECT bec.ID_BECA idBeca,\n" + " bec.ANIO_GESTION anioGestion,\n" + " prb.NOMBRE_PROGRAMA as programaBeca,\n" + " per.NOMBRE_PERSONA nombreBecario,\n" + " per.APELLIDO_PERSONA apellidoBecario,\n" + " per.EMAIL_PERSONA correoBecario,\n" + " fac.NOMBRE_FACULTAD facultad,\n" + "pai.NOMBRE_PAIS paisDestino, org.NOMBRE_ORGANISMO universidadDestino, bec.MONTO_TOTAL montoBeca,IF(bec.OTORGADA = 1, 'SI','NO') as otorgada\n" + "FROM BECA bec\n" + "INNER JOIN PROGRAMA_BECA prb\n" + "ON bec.ID_PROGRAMA_BECA = prb.ID_PROGRAMA\n" + "INNER JOIN PERSONA_BECA peb\n" + "ON bec.ID_BECA = peb.ID_BECA\n" + "INNER JOIN PERSONA per\n" + "ON peb.ID_PERSONA = per.ID_PERSONA\n" + " INNER JOIN CARRERA ca\n" + " ON per.ID_CARRERA = ca.ID_CARRERA\n" + " INNER JOIN FACULTAD fac\n" + " ON ca.ID_FACULTAD = fac.ID_FACULTAD\n" + "INNER JOIN ORGANISMO org\n" + " ON bec.ID_UNIVERSIDAD = org.ID_ORGANISMO\n" + "INNER JOIN PAIS pai\n" + "ON bec.ID_PAIS_DESTINO = pai.ID_PAIS\n" + "WHERE peb.ID_TIPO_PERSONA=6"; if (idBecaSearch > 0) { query = query + " AND bec.ID_BECA=" + idBecaSearch; }// w w w. jav a 2 s.c om query += " ORDER BY bec.ID_BECA DESC"; try { Query q = getSessionFactory().getCurrentSession().createSQLQuery(query) .addScalar("idBeca", new IntegerType()).addScalar("anioGestion", new IntegerType()) .addScalar("programaBeca", new StringType()).addScalar("nombreBecario", new StringType()) .addScalar("apellidoBecario", new StringType()).addScalar("correoBecario", new StringType()) .addScalar("facultad", new StringType()).addScalar("paisDestino", new StringType()) .addScalar("universidadDestino", new StringType()).addScalar("montoBeca", new DoubleType()) .addScalar("otorgada", new StringType()) .setResultTransformer(Transformers.aliasToBean(PojoBeca.class)); return q.list(); } catch (Exception e) { e.printStackTrace(); } return null; }