@Test // @Transactional public void JPANativeQueryTest() { Iterable<CpCtrl> cpCtrlEntries = cpCtrlRepository.cpCtrlTest(2, "01", 2, "1", "20151127"); cpCtrlEntries.forEach( c -> { System.out.println(c.getId().getRegstDay()); System.out.println(c.getId().getRegstTime()); // System.out.println(c.getCtrlParameter().toString()); System.out.println(c.getOutletStat()); System.out.println(c.getRegst()); }); }
@Test // @Transactional public void JPATest() { QB2gHist b2gHist = QB2gHist.b2gHist; Path<?> stDayPath = QB2gHist.b2gHist.id.stDay; Expression<String> constant = Expressions.constant("201511%"); Predicate predicate = Expressions.predicate(Ops.LIKE, stDayPath, constant); Iterable<B2gHist> b2gHistEntries = b2gHistRepository.findAll(predicate); log.info("-------------------" + b2gHistEntries); b2gHistEntries.forEach( h -> { log.info("++++++++++++++++++++++++++++++++++++++++++++++"); log.info(h.getId().getStDay()); log.info(h.getSendResMsg()); log.info(h.getEndDay()); log.info(h.getEndTime()); log.info(h.getSendDay()); log.info(h.getSender()); log.info(h.getUpdateDay()); log.info(h.getUpdateTime()); log.info("-------------------------------------------------"); }); // log.info(netStatRepository.findByReceiverId("EcsiKdn")); log.info("XXXXXXXXXXXXXXXXXXXX com_cd start XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); QComCd comCd = QComCd.comCd; comCd.delYn.coalesce("Y"); comCdRepository .findAll(comCd.delYn.eq("Y").and(comCd.updateDatetime.after(new Date(2010, 7, 1)))) .forEach( c -> { log.info(c.getUpdateDatetime()); log.info(c.getCdDesc()); log.info(c.getCdNm()); log.info(c.getDelYn()); }); log.info("XXXXXXXXXXXXXXXXXXXX com_cd end XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); // ProtocolInfo pi = protocolInfoRepository.findOne(1); Optional<ProtocolInfo> pi = protocolInfoRepository.findOneByProtocolType(2); System.out.println(pi.get().getProtocolName()); System.out.println(pi.get().getProtocolType()); // 조인걸린 데이터 값들 가져오는거 if (pi.isPresent()) { pi.get().getCpCompanyInfo().getEquipInfos().get(0).getCpCompanyInfo().getAddress(); pi.get() .getEquipInfos() .iterator() .forEachRemaining( e -> { log.info(e.getAlterDate()); log.info(e.getAuthKey()); }); // pi.setProtocolVer("jeju version 234324"); // pi.setProtocolName("gwangju protocol 234234"); // protocolInfoRepository.save(pi); protocolInfoRepository .findAll() .forEach( p -> { // update query // p.setProtocolVer("jeju version 2"); // p.setProtocolName("jeju protocol 2"); // protocolInfoRepository.save(p); log.info(p.getCpCompanyInfo()); log.info("||||||||||||||| start equip info ||||||||||||||"); // p.getEquipInfos().iterator().forEachRemaining(e -> { // log.info(e.getAlterDate()); // log.info(e.getAuthKey()); // }); log.info("||||||||||||||| end equip info ||||||||||||||"); log.info(p.getCpCompanyInfo().getHomepage()); log.info(p.getCpCompanyInfo().getFax()); }); } EquipInfo ei = equipInfoRepository.findOne(4); ei.setOpData("This is json string".getBytes()); equipInfoRepository.save(ei); /* Customer customer = new Customer(); Customer cl = customerRepository.findByCustomerNo(234324234L); if (cl.equals(null)) { customer.setCustomerNo(234324234L); customer.setName("Foo"); customer.setMileage(new BigDecimal(2342)); Customer c2 = customerRepository.save(customer); } for (Customer c : customerRepository.findAll()){ log.info(c.getName()); } Customer c = customerRepository.findByName("Foo"); log.info(c.getName()); Address a = new Address(); a.setLine1("abc_test"); a.setCustomer(c); addressRepository.save(a); */ }