Posts

Showing posts with the label hibernate

JPA/Hibernate shared primary key and @OneToOne mapping

JPA/Hibernate shared primary key and @OneToOne mapping Is it possible,when using @OneToOne mapping and shared primary key to insert child object,while updating Parent object? public class Project{ @Id @SequenceGenerator(name = "projectsIdSeq", sequenceName = "PROJECTS_ID_SEQ", allocationSize = 1) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "projectsIdSeq") private Long id; @OneToOne(cascade = CascadeType.ALL) @JoinColumn(name = "ID", referencedColumnName = "PROJECT_ID") @PrimaryKeyJoinColumn private PlanningStageInfo planningStageInfo; } public class PlanningStageInfo{ @Id @Column(name = "PROJECT_ID") private Long projectId; @NotAudited @JsonIgnore @MapsId @OneToOne(mappedBy = "planningStageInfo") private Project project; } When I'm trying to update Project without PlanningStageInfo I'm getting eroor Caused by: org.hibernate.id.IdentifierGenerationException: attempted to as...

How can I choose ideal way for pagination in Spring boot?

Image
How can I choose ideal way for pagination in Spring boot? I need your advice for paginations. My table data is very long.Therefor I use pagination and every pag action İ call data from database I have a rest method in spring-boot application. This method could get data from database and everthing is ok. I need pag count(all count of my data/ perPage count). I can find this count from db. I must write two seperate method for allCount and the below method? How can I use ideal way for pagination in Spring boot? @CrossOrigin(maxAge = 3600) @RequestMapping(value = "/payment/all", method = RequestMethod.POST) public List<NotaryPaymentInformationEntity> getAllProduct(@RequestBody PaginationModel pag){ try { System.out.println(pag.getPageno()+ " " + pag.getRecords()); Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } Pageable pageable = new PageRequest(pag.getPage...

Cannot find class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactory] for bean with name 'sessionFactory'

Cannot find class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactory] for bean with name 'sessionFactory' i created a project in spring using maven dependencies but i am getting the above mentioned error. i changed the version of hibernate dependency but stil it does nt get resolved here is the code: pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.shr</groupId> <artifactId>apps</artifactId> <name>SpringJdbcProject</name> <packaging>war</packaging> <version>1.0.0-BUILD-SNAPSHOT</version> <properties> <java-version>1.6</java-version> <org.springframework-...