Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package demo;
- import javax.persistence.Entity;
- import javax.persistence.GeneratedValue;
- import javax.persistence.Id;
- import javax.persistence.Table;
- import org.hibernate.annotations.GenericGenerator;
- import org.hibernate.annotations.Parameter;
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
- import org.springframework.data.jpa.repository.JpaRepository;
- @SpringBootApplication
- public class App {
- public static void main(String[] args) {
- CustomerRepository customerRepository = SpringApplication.run(App.class, args)
- .getBean(CustomerRepository.class);
- Customer customer = new Customer();
- customer.setName("customer" + System.currentTimeMillis());
- customerRepository.save(customer);
- }
- }
- interface CustomerRepository extends JpaRepository<Customer, Long> {
- }
- @Entity
- @Table(name = "customer")
- class Customer {
- @Id
- @GeneratedValue(generator = "pooled")
- @GenericGenerator(name = "pooled", strategy = "enhanced-table", parameters = {
- @Parameter(name = "value_column_name", value = "sequence_next_hi_value"),
- @Parameter(name = "prefer_entity_table_as_segment_value", value = "true"),
- @Parameter(name = "optimizer", value = "pooled-lo"), @Parameter(name = "increment_size", value = "100") })
- Long id;
- String name;
- public Long getId() {
- return id;
- }
- public void setId(Long id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement