天道酬勤,学无止境

orm

Spring MVC 应用程序语法错误(Spring MVC Application syntax error)

问题 我有这个问题: Spring MVC 应用程序 我用一些新代码解决了这个问题,制作了StudentDeleteRepository.java和StudentDeleteRepositoryImpl.java并按照用户的建议添加了标签: @Autowired private StudentDeleteRepository studentDeleteRepository; @Transactional public Student delete(Student student) { return studentDeleteRepository.save(student); } StudentDeleteRepository.java给出了错误: org.springframework.beans.factory.BeanCreationException:创建名为“studentDeleteController”的 bean 时出错:自动装配依赖项的注入失败; 嵌套异常是 org.springframework.beans.factory.BeanCreationException:无法自动装配字段:private com.github.elizabetht.service.StudentDeleteService com.github.elizabetht.controller

2021-10-26 00:01:54    分类:技术分享    java   spring   spring-mvc   jpa   orm

How to define a Doctrine mappedSuperclass using XML or YAML instead of annotation mapping

The following script comes from https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html#mapped-superclasses, and was only changed to include a second sub-class. It is my understanding that MappedSuperclassBase cannot exist by itself but must be extended by one and only one sub-class (i.e. either EntitySubClassOne or EntitySubClassTwo), and is the same concept as supertype/subtype for SQL. Agree? How is a super/sub type defined using either YAML or XML instead of annotation mapping? <?php /** @MappedSuperclass */ class MappedSuperclassBase { /** @Column

2021-10-25 22:48:47    分类:问答    orm   doctrine-orm   doctrine   superclass   supertype

AS3-Spod Example or tutorial? or any other AS3 ORM

Does anybody have any experience with as3-spod? I downloaded the source code from github and as3-signals and started to try it out, but I´ll take ages to get to know the framework by trial and error and probably miss a lot of best practices. The framework looks good but lack's on examples. The git page does't have a lot of info on that... If anybody knows some other ORM for AIR that I can use on pure AS3 projects that have any bit of documentation, I´m more than thankful!

2021-10-25 22:39:58    分类:问答    actionscript-3   orm   air

doesn't driving query pattern cause N+1 problem?

In spring batch reference, there is a pattern called driving query pattern https://docs.spring.io/spring-batch/4.1.x/reference/html/common-patterns.html#drivingQueryBasedItemReaders I don't know if I misunderstand this pattern right, doesn't driving query pattern cause N+1 problem? It looks like a classic N+1 problem to me, especially they are bad practice in ORM world.

2021-10-25 21:42:58    分类:问答    orm   spring-batch

Hibernate Storing Fields inside Classes

I have two classes with two individual tables, "Employee" and "Company". I would like to keep a list of employee inside Company class. It is easy but I do not know how to represent this list in the database side. Class 'Company': @Entity @Table(name = "company") public class Company { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private Integer id; @Column(name = "name") private String name; private List<Employee> employeeList; } Class 'Employee': @Entity @Table(name = "employee") public class Employee { @Id @GeneratedValue(strategy = GenerationType.IDENTITY)

2021-10-25 20:14:42    分类:问答    java   hibernate   orm   relational-database

JPA Inheritence IdClass

How to use IdClass in multiple inheritance entity composite key case ? @IdClass(IdClassEntity1.class) class Entity1 { private long e1pk1; private long e1pk2; } @IdClass(IdClassEntity2.class) class Entity2 extends Entity1 { private long e2pk1; private long e2pk2; } class Entity3 extends Entity2 { private long e3pk1; private long e3pk2; } what should be IdClassEntity2 : class IdClassEntity2 { private long e1pk1; private long e1pk2; private long e2pk1; private long e2pk2; } or class IdClassEntity2 { private IdClassEntity1 idClassEntity1; private long e2pk1; private long e2pk2; }

2021-10-25 19:39:52    分类:问答    java   jpa   orm   jpa-2.0

参考文献/有一个映射到 3 个表(References/has-a mapping thru 3 tables)

问题 我的模型对象Reading有一个Location但它在数据库中不是直接关系。 在数据库中,这个“有一个”关系或“引用”跨越 3 个表,如下图所示: 我的Reading映射到 ComponentReading 表,我希望我的Location映射到位置表。 我的ClassMap<Reading>类现在看起来像这样: public class ReadingMap : ClassMap<Reading> { public ReadingMap() { Table("ComponentReading"); Id(x => x.ID).Column("ComponentReadingId"); //References(x => x.Location).Formula( Join("VehicleReading", vr => { Join("TrainReading", tr => { tr.References(x => x.Location, "LocationId"); }); }); Map(x => x.TemperatureValue).Column("Temperature"); } } 这是我的简单Location映射: public class LocationMap : ClassMap<Location> { public LocationMap() { Id

2021-10-25 18:37:02    分类:技术分享    nhibernate   orm   join   fluent-nhibernate   domain-driven-design

Django:通过ID获取最后一条记录[多对一关系](Django: Get last record by ID [many-to-one relationship])

问题 我正在尝试使用 Django 模型中的多对一关系将一个表中的最后一条记录连接到另一个表。 这是我的 Django 模型: class DataCollecttion(models.Model): default_name = models.CharField(max_length=100) class NameHistory(models.Model): old_name = models.CharField(max_length=100) collection_data = models.ForeignKey(DataCollection, on_delete=models.CASCADE, null=True) 在这里,我为DataCollection表创建了一个示例数据: 这是NameHistory表的示例数据: 我在这里想要的是过滤或获取每个collection_data_id中NameHistory中的最后一条记录(红色矩形内的记录)并将其显示在我的视图中。 所以简而言之,我想获得这些行,以及如何在 ORM 查询中做到这一点: sample3 test2 data1 回答1 你需要一个窗口函数: 窗口函数提供了一种在分区上应用函数的方法。 与为 group by 定义的每个集合计算最终结果的普通聚合函数不同,窗口函数对帧和分区进行操作,并计算每一行的结果。

2021-10-25 15:23:50    分类:技术分享    django   database   django-models   orm   python-3.7

SpringBoot Rest Controller中与Jackson @JsonIgnore合作MongoDB延迟加载(Cooperation MongoDB lazy loading with Jackson @JsonIgnore in SpringBoot Rest Controller)

问题 我在SpringBoot应用程序中编写了一个RestController 。 我也在使用MongoDB 。 这是我的实体: public class LocationEntity { @Id private String id; private String name; @DBRef(lazy = true) @JsonIgnore private UserEntity owner; private String description; @DBRef(lazy = true) private List<RoleEntity> roles; private Date date; public LocationEntity(String name, UserEntity owner, String description, List<RoleEntity> roles, Date date) { this.name = name; this.owner = owner; this.description = description; this.roles = roles; this.date = date; } } RoleEntity和UserEntity也是来自同一数据库的实体。 我的RestController的方法返回ResponseEntity

2021-10-25 10:32:19    分类:技术分享    java   mongodb   orm   jackson   lazy-loading

如何创建查询并添加要按顺序选择的列?(How to create a query and add columns to select sequentially?)

问题 我需要构建一个查询,其中结果中的选定列正在发生变化。 如何将列添加到逐渐类似于.filter的结果中: query = session.query(User).filter(name == 'Hansen').filter(country == 'Spain') 谢谢! 回答1 sqlalchemy Query 类有一个 add_columns 方法可用于此目的。 cols = ['col1', 'col2', 'col3', 'col4'] q = session.query() for c in cols: q = q.add_columns(getattr(MyTable, c)) res = q.all() 顾名思义,该方法将接受多个列表达式。 q.add_columns(*list_of_columns) Query.add_entity 将用于向查询添加一个 orm 实体,例如模型类。 q = session.query() q = q.add_entity(MyTable) # Fetch objects, not just columns list_of_objs = q.all()

2021-10-25 09:30:21    分类:技术分享    python   orm   sqlalchemy