orm

Is there are way to scroll results with JPA/hibernate?

﹥>﹥吖頭↗ 提交于 2020-12-01 06:43:40
问题 I found some hint in Toplink Query query = em.createQuery("SELECT e FROM Employee e ORDER BY e.lastName ASC, e.firstName ASC"); query.setHint("eclipselink.cursor.scrollable", true); ScrollableCursor scrollableCursor = (ScrollableCursor)query.getSingleResult(); List<Employee> emps = scrollableCursor.next(10); is there are jpa/hibernate alternative? 回答1: To my knowledge, there is nothing standard in JPA for that. With Hibernate, the closest alternative I'm aware of would be the Query /

Dapper map multiple joins Sql Query

微笑、不失礼 提交于 2020-11-30 04:34:38
问题 I want to map complex object to dapper result from query which has two inner joins. I know we've solution to map one inner join but I want to map two inner joins result. Here is the Scenario: My Classes are: public class Order { public int id { get; set; } public string order_reference { get; set; } public string order_status { get; set; } public List<OrderLine> OrderLines { get; set; } } public class OrderLine { public int id { get; set; } public int order_id { get; set; } public string

Dapper map multiple joins Sql Query

狂风中的少年 提交于 2020-11-30 04:29:30
问题 I want to map complex object to dapper result from query which has two inner joins. I know we've solution to map one inner join but I want to map two inner joins result. Here is the Scenario: My Classes are: public class Order { public int id { get; set; } public string order_reference { get; set; } public string order_status { get; set; } public List<OrderLine> OrderLines { get; set; } } public class OrderLine { public int id { get; set; } public int order_id { get; set; } public string

SQLAlchemy: How do you delete multiple rows without querying

流过昼夜 提交于 2020-11-30 03:02:05
问题 I have a table that has millions of rows. I want to delete multiple rows via an in clause. However, using the code: session.query(Users).filter(Users.id.in_(subquery....)).delete() The above code will query the results, and then execute the delete. I don't want to do that. I want speed. I want to be able to execute (yes I know about the session.execute): Delete from users where id in () So the Question: How can I get the best of two worlds, using the ORM? Can I do the delete without hard

SQLAlchemy: How do you delete multiple rows without querying

∥☆過路亽.° 提交于 2020-11-30 02:58:59
问题 I have a table that has millions of rows. I want to delete multiple rows via an in clause. However, using the code: session.query(Users).filter(Users.id.in_(subquery....)).delete() The above code will query the results, and then execute the delete. I don't want to do that. I want speed. I want to be able to execute (yes I know about the session.execute): Delete from users where id in () So the Question: How can I get the best of two worlds, using the ORM? Can I do the delete without hard

How to save relation in @ManyToMany in typeORM

本秂侑毒 提交于 2020-11-25 02:05:06
问题 There are 2 entities named Article and Classification . And the relation of them is @ManyToMany . Here's my question: How to save the relation? My code as below: @Entity() export class Article { @PrimaryGeneratedColumn() id: number; @Column() name: string; @CreateDateColumn() createTime: Date; @UpdateDateColumn() updateTime: Date; @Column({ type: 'text', }) content: string; @Column({ default: 0, }) likeAmount: number; @Column({ default: 0, }) commentAmount: number; } @Entity() export class