hibernate-mapping

How should I register custom Hibernate 5 data type (BasicType) when Spring Data is used?

此生再无相见时 提交于 2020-06-24 11:48:07
问题 I use Spring Data and decided that I want to create new custom data type that can be used in Hibernate entities. I checked the documentation and choose BasicType and implemented it according to this official user guide. I wanted to be able to register the type under its class name and be able to use the new type in entities without need for @Type annotation. Unfortunately, I’m unable to get reference to the MetadataBuilder or Hibernate configuration to register the new type. Is there a way

Hibernate one to many mapping foreign key issue

寵の児 提交于 2020-05-30 08:23:23
问题 I am new to hibernate. Please help me in understanding this. I have Department and Employee objects. Department is having employee collection with cascade type SAVE.I have created department object and employee object.lets say dept1 and emp1 respectively.When I save dept1 object(which is having emp1) ,it is saving dept1 and emp1 in department and employee tables with out foreign key. Unless I am setting department(dept1) on emp1 , it is not saving foreign key. why should i manually set that?

Unidirectional @OneToOne with @MapsId does not work with lazy loading

大城市里の小女人 提交于 2020-05-29 08:42:26
问题 I want to map a @OneToOne association using Hibernate 5.3.10 and JPA. I know that the parent side of a @OneToOne association cannot be loaded lazily when not using bytecode enhancements. In this case, I only want to map the client side and use @MapsId association which is suggested here: Best way to map onetoone Here is my mapping on the Client side. The parent side CardEntity has no mapping to the DeviceType at all. public class DeviceType { @Id @Column( name = "PRODUCT_CARD_TYPE_ID" )

How can I send data in POST body without setting the auto generated primary key values in Spring Boot?

不想你离开。 提交于 2020-05-17 07:43:11
问题 I have two classes/tables--- Customer and Address having a bi-directional one-to-one relationship. Address_id is the foreign key. Here is the entity diagram I am trying to send data through postman, but I want to send the values without setting the primary key attributes in the post body. It is working if I omit the id attribute in for customer only. But its not working if i do the same for address. This is the post body for which data is successfully getting inserted. <Customer> <firstName

Grails: domain object sort mapping not working

♀尐吖头ヾ 提交于 2020-05-16 21:58:33
问题 Here is my domain object: package org.olr.nonadmin import org.olr.admin.User class Question { // Integer id // autogenerated by db // Integer version // autogenerated integer Date dateCreated // auto filled Date lastUpdated // auto filled String qText // question text - can contain markup! String aText // answer text - can contain markup! boolean publik // public to all usersot needed String figureBase64 // image in BASE64 format, used in data-URI for figure String figureName // figure name

How to map calculated properties with JPA and Hibernate

时光怂恿深爱的人放手 提交于 2020-04-30 06:38:14
问题 My Java bean has a childCount property. This property is not mapped to a database column . Instead, it should be calculated by the database with a COUNT() function operating on the join of my Java bean and its children. It would be even better if this property could be calculated on demand / "lazily", but this is not mandatory. In the worst case scenario, I can set this bean's property with HQL or the Criteria API, but I would prefer not to. The Hibernate @Formula annotation may help, but I

SpringBoot+Kotlin+Postgres and JSONB: “org.hibernate.MappingException: No Dialect mapping for JDBC type”

我的梦境 提交于 2020-04-28 21:28:43
问题 The bounty expires in 4 days . Answers to this question are eligible for a +50 reputation bounty. paranza is looking for an answer from a reputable source . I have been consulting a number of approaches/posts/stackoverflow questions in order to deal with the following error (full stack trace) when running a Kotlin/SpringBoot application: 2020-04-22 18:33:56.823 ERROR 46345 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory

SpringBoot+Kotlin+Postgres and JSONB: “org.hibernate.MappingException: No Dialect mapping for JDBC type”

て烟熏妆下的殇ゞ 提交于 2020-04-28 21:24:19
问题 The bounty expires in 4 days . Answers to this question are eligible for a +50 reputation bounty. paranza is looking for an answer from a reputable source . I have been consulting a number of approaches/posts/stackoverflow questions in order to deal with the following error (full stack trace) when running a Kotlin/SpringBoot application: 2020-04-22 18:33:56.823 ERROR 46345 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory

Bug in Spring Data JPA: Spring Data returns List<BigInteger> instead of List<Long>

瘦欲@ 提交于 2020-04-08 02:56:17
问题 I have DAO implementation over spring-data: public interface TestDataRepository extends CrudRepository<DpConfigData, Long> { @Query(value = "select distinct(oid) from unit", nativeQuery = true) List<Long> testMethod(); } And unit test to test menioned DAO: @Test public void test(){ List<Long> testData = dpConfigDataEntityDataRepository.testMethod(); for (Long oid:testData){ System.out.print(oid); } } Running test give strange result - List<Long> testData in runtime is populated by BigInteger

“Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements”

为君一笑 提交于 2020-01-30 15:25:09
问题 Good morning Stackoverflow, I have the problem that it gives me the error: Failed to create sessionFactory object.org.hibernate.AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: nl.scalda.pasimo.model.employeemanagement.EducationTeam.coachGroups Do you know why? @OneToMany(cascade=CascadeType.ALL, targetEntity=CoachGroup.class) @JoinColumn(name="id") private TreeSet<CoachGroup> coachGroups = new TreeSet<>(); private