<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ~~~ package net.youworker.domain; import net.youworker.repository.CustomerRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.domain.Example; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.Optional; @RunWith(SpringRunner.class) @SpringBootTest public class CustomerTest { @Autowired private CustomerRepository customerRepository; /** * 查詢全部 */ @Test public void testFindAll() { List<Customer> customerList = customerRepository.findAll(); for (Customer customer : customerList) { System.out.println(customer); System.out.println(customer.getCustName()); } } /** * 根據id查詢 */ @Test public void testFindById() { Optional<Customer> customer = Optional.ofNullable(customerRepository.findById(6l).orElse(null)); System.out.println(customer.get()); System.out.println(customer.get().getCustName()); } /** * 保存或者更新 * 根據傳遞的對象是否存在主鍵id * 如果沒有Id主鍵屬性:保存 * 存在id主鍵屬性:根據id查詢數據,更新數據 */ @Test public void testSave() { try { Customer customer = new Customer(); customer.setCustName("大腳"); customer.setCustPhone("1955455"); customer.setCustAddress("sdsdssd"); customer.setCustIndustry("sdsds"); customer.setCustSource("來源"); customer.setCustLevel("55"); Customer save = customerRepository.save(customer); System.out.println("customer1"); System.out.println(save); } catch (Exception e) { System.out.println(e.getStackTrace()); System.out.println(e.getMessage()); } } /** * 更新 */ @Test public void update() { Customer customer = new Customer(); customer.setCustId(2l); customer.setCustIndustry("大專"); customer.setCustAddress("鐵嶺"); customer.setCustLevel("555"); customer.setCustPhone("199998855"); customer.setCustSource("來源..."); customer.setCustName("大腳腳"); Customer save = customerRepository.save(customer); System.out.println("更新"); System.out.println(save); } /** * 刪除 */ @Test public void delete() { try { Customer customer = new Customer(); customer.setCustId(2l); customerRepository.delete(customer); // customerRepository.deleteById(1l); System.out.println("刪除成功!!"); } catch (Exception e) { System.out.println(e.getMessage()); } } //復雜查詢 /** * 統計 */ @Test public void testCount() { long count = customerRepository.count(); System.out.println("count"); System.out.println(count); } /** * 查詢是否存在 */ @Test public void testExists() { boolean exists = customerRepository.existsById(2l); System.out.println("id為2的客戶是否存在:" + exists); } /** * 根據id從數據庫查詢 * * @Transactional : 保證getOne正常運行 * findOne: * em.find() * getOne: * em.getRefrence * 延時加載(懶加載) getOne */ @Test @Transactional public void testGetOne() { // Customer customer = customerRepository.getOne(3l); // System.out.println(customer); Customer customer = new Customer(); customer.setCustId(3l); Example<Customer> example = Example.of(customer); Optional<Customer> optionalCustomer = customerRepository.findOne(example); System.out.println(optionalCustomer.get().getCustName()); } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看