persistence

Hibernate and tables with same data/columns but with different table names

可紊 提交于 2020-08-07 07:11:27
问题 The database I am working with has many tables with the same columns but with (obviously) different table names (I didn't design it). For example (these are database table names): company1Data company2Data company3Data etc. Would it be possible to map these to one Java class entity with JPA and hibernate? The name of the class would be Data , and then pass in for example company1 somewhere when using it so that object would use the company1Data table? Or is it better to just use normal, plain

Hibernate and tables with same data/columns but with different table names

我们两清 提交于 2020-08-07 07:10:20
问题 The database I am working with has many tables with the same columns but with (obviously) different table names (I didn't design it). For example (these are database table names): company1Data company2Data company3Data etc. Would it be possible to map these to one Java class entity with JPA and hibernate? The name of the class would be Data , and then pass in for example company1 somewhere when using it so that object would use the company1Data table? Or is it better to just use normal, plain

Persistence: Data Trees stored as Directory Trees

做~自己de王妃 提交于 2020-07-09 08:31:28
问题 I was wondering as to the practicalities of storing an in memory tree structure as directory tree for persistence purposes. In my case he target filesystem will be ZFS, and once the structure has been created it will be accessed by multiple processes infrequently. How performant is using a Directory Tree as a mechanism of persistence for Data Trees? 回答1: In order to read and write your tree, you will be calling the filesystem several times per node. This is much more expensive than any sane

How to properly pickle sklearn pipeline when using custom transformer

冷暖自知 提交于 2020-06-11 17:00:09
问题 I am trying to pickle a sklearn machine-learning model, and load it in another project. The model is wrapped in pipeline that does feature encoding, scaling etc. The problem starts when i want to use self-written transformers in the pipeline for more advanced tasks. Let's say I have 2 projects: train_project: it has the custom transformers in src.feature_extraction.transformers.py use_project: it has other things in src, or has no src catalog at all If in "train_project" I save the pipeline

Kotlin - return new inserted id from Room database using Persistence Room:runtime lib

二次信任 提交于 2020-04-10 03:55:14
问题 I am trying to insert user record in Room database using Kotlin and It's working perfectly. And now I want to return newly inserted record id to check if a record is successfully inserted or not in Room database. But when I am applying Long return type in the insert method and run the code that time I get the following error. error: Method returns long but it should return one of the following: void, long[], java.lang.Long[], java.util.List<java.lang.Long> . If you want to return the list of

Kotlin - return new inserted id from Room database using Persistence Room:runtime lib

不打扰是莪最后的温柔 提交于 2020-04-10 03:54:10
问题 I am trying to insert user record in Room database using Kotlin and It's working perfectly. And now I want to return newly inserted record id to check if a record is successfully inserted or not in Room database. But when I am applying Long return type in the insert method and run the code that time I get the following error. error: Method returns long but it should return one of the following: void, long[], java.lang.Long[], java.util.List<java.lang.Long> . If you want to return the list of

Hibernate not correctly saving an Object in the db (?, ?, ?, ?)

那年仲夏 提交于 2020-03-25 13:44:14
问题 Following from this question. (I'm using Hibernate 4.) As suggested in one of the answers I tried using the FeedbackDto-Feedback approach. Inside my RequestsController.java I have this: @PostMapping("/feedback") public void postFeedback(@RequestBody FeedbackDto feedbackDto) { Feedback feedback = new Feedback(new Product(feedbackDto.getProductId()), feedbackDto.getScore(), feedbackDto.isPreferred(), feedbackDto.getTextNote()); Session session = HibernateUtil.getSessionFactory().openSession();

Hibernate: persistence optimization of lengthy ArrayLists

我的未来我决定 提交于 2020-03-23 09:53:18
问题 I've come across multiple bottlenecks in my database usage. I'm using PostgreSQL accessed with Hibernate ORM and written in Java 8. Here's a sample of the class that needs optimization : public class RightEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @ElementCollection @LazyCollection(LazyCollectionOption.FALSE) private List<Long> readableEntity = new ArrayList<Long>(); } RightEntity is an object which allows the access of a list of Ids (List of Long). The