This article mainly introduces the actual application of Date and sequence in Oracle Hibernate in the form of code. If you are puzzled by the actual application and operation of Date and sequence in Oracle Hibernate, you can read the following articles to learn about it.
Date and sequence in Oracle Hibernate
- Ocreate table tb_bill (
- bill_id INTEGER not null,
- shop_id INTEGER,
- bill_content VARCHAR2(200),
- bill_handler VARCHAR2(20),
- billdate DATE,
- constraint PK_TB_PRICEBILL primary key (bill_id)
- );
Sequence:
- create sequence SEQ_TB_BILL
Configuration file:
- <id name="id" unsaved-value="0">
- <column name="bill_id"/>
- <generator class="sequence">
- <param name="sequence">SEQ_TB_BILL </param>
- </generator>
- </id>
- <property name="shopId" column="shop_id"/>
- <property name="billcontent" column="bill_content"/>
- <property name="billHandler" column="bill_handler"/>
- <property name="billDate" column="billdate" type=
"" type="timestamp"/>
- bean:
- private int shopId;
- private String billcontent;
- private String billHandler;
- private Date billDate;
Date and sequence methods in Oracle Hibernate are automatically generated without writing them! Follow the steps below to save the bean:
- Bill model = new Bill();
- model.setBillcontent("neirong");
- model.setBillHandler("handler");
- model.setBillPrice(123.02);
- model.setShopId(2);
- BillDAO.save(model);
- System.out.println(model.getId());
If the problem occurs, then the Date database, when a new java. util. it is normal that the Date () is retained, but the bill_id of the sequence has a problem. The number is too large, leading to exceeding the int range, if the billDate field in the database is removed, everything is normal and bill_id is saved as normal. The method is normal in other classes.
This is abnormal. Other classes also have time for Date, which is extremely depressing for two days. Later, the time will be automatically saved from the database! The above is an introduction to Date and sequence related content in Oracle Hibernate. I hope you will gain some benefits.