orm

which SessionFactory should be use for transactionManager?

爱⌒轻易说出口 提交于 2020-01-14 03:43:50
问题 <bean id="projectService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager" ref="transactionManager"/> <property name="target"> <bean class="com.company.project.company.services.ServiceImpl" init-method="init"> <property name="HRappsdao" ref="HRappsdao"/> <property name="projectdao" ref="projectdao"/> </bean> </property> <property name="transactionAttributes"> <props> <prop key="store*">PROPAGATION_REQUIRED</prop> <prop key=

.NET(C#)有哪些主流的ORM框架

拈花ヽ惹草 提交于 2020-01-14 02:09:13
前言 在以前的一篇文章中,为大家分享了《 什么是ORM?为什么用ORM?浅析ORM的使用及利弊 》。那么,在目前的.NET(C#)的世界里,有哪些主流的ORM,SqlSugar,Dapper,Entity Framework(EF)还是ServiceStack.OrmLite? 或者是你还有更好的ORM推荐呢? 如果有的话,不防也一起分享给大家。 .NET(C#)主流ORM总揽 今天这篇文章分享几款收集的目前.NET(C#)中比较流行的ORM框架,比如(以下框架均为开源框架,托管于github上): SqlSugar (国内) Dos.ORM (国内) Chloe (国内) StackExchange/Dapper (国外) Entity Framework (EF) (国外) NHibernate (国外) ServiceStack/ServiceStack.OrmLite (国外) linq2db (国外) Massive (国外) PetaPoco (国外) SqlSugar SqlSugar是国人开发者开发的一款基于.NET的ORM框架,是可以运行在.NET 4.+ & .NET CORE的高性能、轻量级 ORM框架,众多.NET框架中最容易使用的数据库访问技术。 特点: 开源、免费 国内开发者开发、维护; 支持.NET Core; 支持主流数据库,如:SQL Server

ORM PHP 学习记录

喜夏-厌秋 提交于 2020-01-14 01:44:12
ORM:object relation mapping,即对象关系映射,简单的说就是对象模型和关系模型的一种映射。为什么要有这么一个映射?很简单,因为现在的开发语言基本都是oop的,但是传统的数据库却是关系型的。为了可以靠贴近面向对象开发,我们想要像操作对象一样操作数据库。 举个例子:获取一篇文章,传统的方式先要执行一个sql检索数据 select * from post where id = 1 然后输出标题和内容使用 echo $post['title']; echo $post['content']; 上面的代码遇到面向对象强迫症者,他们会纠结死的。 所以他们想出了这个东西,在ORM里获取一篇文章可以这样: $post = postTable::getInstance()->find(1);#会再内部执行select * from post where id = 1 然后输出: echo $post->getTitle(); echo $post->getContent(); 妈妈再也不用担心我的强迫症了^_^ 高级点的应用,文章和分类是一对多关系、文章和标签是多对多关系 $cate = $post->getCategory(); //获取文章分类 echo $cate->getName(); //获取分类名 $tags = $post->getTags(); /

Django, in many to many relationship within the self class, how do I reference each other in terms of ORM?

落花浮王杯 提交于 2020-01-13 18:04:14
问题 class User(models.Model): name = models.CharField(max_length=100) age = models.IntegerField() gender = models.IntegerField() email = models.CharField(max_length=100) password = models.CharField(max_length=255) following = models.ManyToManyField("self", related_name='followers') objects = UserManager() def __repr__(self): return "User: {0}".format(self.name) In my model, User, users can follow and followed by each other. I can find who the user is following by this: user1 = User.objects.get(id

Django, in many to many relationship within the self class, how do I reference each other in terms of ORM?

北慕城南 提交于 2020-01-13 18:02:04
问题 class User(models.Model): name = models.CharField(max_length=100) age = models.IntegerField() gender = models.IntegerField() email = models.CharField(max_length=100) password = models.CharField(max_length=255) following = models.ManyToManyField("self", related_name='followers') objects = UserManager() def __repr__(self): return "User: {0}".format(self.name) In my model, User, users can follow and followed by each other. I can find who the user is following by this: user1 = User.objects.get(id

Symfony2 and Doctrine, Column cannot be null with OneToOne relationships

微笑、不失礼 提交于 2020-01-13 17:58:09
问题 Here is an entity ( EDITED: full file content ) // Eve\MoonBundle\Entity\MoonMaterial.php namespace Eve\MoonBundle\Entity; use Doctrine\ORM\Mapping as ORM; //use Doctrine\Common\Collections\ArrayCollection; /** * @ORM\Table(name="_moon_material") * @ORM\Entity() */ class MoonMaterial { public function __construct() { //$this->invTypes_byTypeID = new ArrayCollection(); } // relations start /** * @ORM\OneToOne(targetEntity="Eve\DumpBundle\Entity\invTypes") * @ORM\JoinColumn(name="typeID",

NoPrimaryKeyException from DBUnit when loading a dataset into a database

依然范特西╮ 提交于 2020-01-13 14:43:54
问题 I'm getting NoPrimaryKeyException when I try to run one of my unit tests which uses DBUnit. The datatable is created using Hibernate and is a join table between two classes mapping a many to many relationship. The annotations that define the relationship are as follows: @Override @ManyToMany @JoinTable(name="offset_file_offset_entries", joinColumns={@JoinColumn(name="offset_entry_id")},inverseJoinColumns={@JoinColumn(name="file_description_id")}) public List<OffsetEntry> getOffsets() { The

Doctrine 2 Pagination with Association Mapping

坚强是说给别人听的谎言 提交于 2020-01-13 13:50:32
问题 I am wondering how can you paginate the results obtained from an entity association mapping in Doctrine 2? For example class Customer { /** * @OneToMany(targetEntity="Order") */ private $orders; } can be used as such: $customer->getOrders(); which will return a collection of Order objects. The problem is when there are a large number of order objects. We can use Doctrine\ORM\Tools\Pagination\Paginator when building custom queries, however I do not see any way to hook into query generation

Doctrine DQL RIGHT JOIN?

ε祈祈猫儿з 提交于 2020-01-13 12:19:12
问题 Is it possible to do a RIGHT OUTER JOIN in Doctrine 2 DQL? 回答1: As far as I know, there is still no way to do that in DQL, and the reason might be that it does not make much sense from an ORM perspective, according to one of the lead developers. Nevertheless, the feature request, although very old, is still open; so it might be implemented in the future. 来源: https://stackoverflow.com/questions/7957987/doctrine-dql-right-join

How to map combinations of things to a relational database?

允我心安 提交于 2020-01-13 11:35:30
问题 I have a table whose records represent certain objects. For the sake of simplicity I am going to assume that the table only has one column, and that is the unique ObjectId . Now I need a way to store combinations of objects from that table. The combinations have to be unique, but can be of arbitrary length. For example, if I have the ObjectId s 1,2,3,4 I want to store the following combinations: {1,2}, {1,3,4}, {2,4}, {1,2,3,4} The ordering is not necessary. My current implementation is to