标签: orm

在现有数据库sqlite sugar orm中创建表

我已经创建了使用的现有数据库SQLiteOpenHelper,但现在我想转移到Sugar Orm并尝试在现有数据库中添加新表.我正在关注糖orm页面(Sugar Orm Configuration)的配置页面上提到的所有要点.

这是我的配置的样子,

AndroidManifest.xml中

<application
    android:name=".application"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <meta-data android:name="DATABASE" android:value="database.db" />
    <meta-data android:name="VERSION" android:value="5" />
    <meta-data android:name="QUERY_LOG" android:value="true" />
    <meta-data android:name="DOMAIN_PACKAGE_NAME" android:value="com.example.in.smart" />
Run Code Online (Sandbox Code Playgroud)

application.java(应用程序类)

public class application extends com.orm.SugarApp
 {
private static Context instance;
 public static Context get() {
    return application.instance;
}
Run Code Online (Sandbox Code Playgroud)

模型类

public class Now extends SugarRecord<Now> {
public String type = null;
public String name = null;
public String address = null;
public Date created;

public Now(){}

public …
Run Code Online (Sandbox Code Playgroud)

java sqlite orm android sugarorm

1
推荐指数
1
解决办法
6013
查看次数

如何在没有额外查询的情况下删除sequelize中的关联?

exercisemuscle模型之间有很多很多关联.我删除单一关联

models.Exercise.find({where: {id: exerciseId}})
                .then(function(exercise){
                    exercise.removeMuscle(muscleId);
                    res.sendStatus(200);
                });
Run Code Online (Sandbox Code Playgroud)

ORM运行3个查询,其中2个类似

Executing (default): SELECT `Muscule`.`id`, `Muscule`.`title`, `Muscule`.`description`, `Muscule`.`video`, `Muscule`.`createdAt`,
    `Muscule`.`updatedAt`, `muscle_exercise`.`createdAt` AS `muscle_exercise.createdAt`, `muscle_exercise`.`updatedAt` AS `muscle_
    exercise.updatedAt`, `muscle_exercise`.`MusculeId` AS `muscle_exercise.MusculeId`, `muscle_exercise`.`ExerciseId` AS `muscle_exercise.ExerciseId` FROM `Muscules` AS `Muscule` INNER JOIN `muscle_exercise` AS `muscle_exercise` ON `Muscule`.`id` = `muscle_exercise`.`MusculeId` AND `muscle_exercise`.`ExerciseId` = 11;



 Executing (default): SELECT `Muscule`.`id`, `Muscule`.`title`, `Muscule`.`description`, `Muscule`.`video`, `Muscule`.`createdAt`,
    `Muscule`.`updatedAt`, `muscle_exercise`.`createdAt` AS `muscle_exercise.createdAt`, `muscle_exercise`.`updatedAt` AS `muscle_
    exercise.updatedAt`, `muscle_exercise`.`MusculeId` AS `muscle_exercise.MusculeId`, `muscle_exercise`.`ExerciseId` AS `muscle_exercise.ExerciseId` FROM `Muscules` AS `Muscule` INNER JOIN …
Run Code Online (Sandbox Code Playgroud)

mysql orm node.js sequelize.js

1
推荐指数
1
解决办法
7490
查看次数

Hibernate HQL JOIN - 获取的关联不存在

有这个课程:

public class Device implements java.io.Serializable {

    private Set<Product> products = new HashSet<Product>(0);
    private Set<Service> services = new HashSet<Service>(0);

    @OneToMany (fetch = FetchType.LAZY, mappedBy = "device", cascade = {     CascadeType.REMOVE })
    @Cascade({ org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
    @OrderBy("id")
    public Set<Product> getProducts() {
        return this.products;
    }

   @OneToMany (fetch = FetchType.LAZY, mappedBy = "device", cascade = {     CascadeType.REMOVE })
    @Cascade({ org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
    @OrderBy("id")
    public Set<Service> getServices() {
        return this.services;
    }    
}
Run Code Online (Sandbox Code Playgroud)

我想使用带有关联和连接的Hibernate查询语言来执行此查询,hibernate的版本是3.2.6

@Override
    public int numberofProductsOrServices(String licenseNumber) {

        String queryString = "select count(*) as n …
Run Code Online (Sandbox Code Playgroud)

java orm hibernate jpa hql

1
推荐指数
1
解决办法
2496
查看次数

传统的sql方法VS ORM

我真的很沮丧地搜索这个答案,哪个更好 - 传统的System.Data.SqlClient方法或使用任何ORM,如EF或Dapper我通过许多链接看到了很多比较,有些是:

  1. https://github.com/StackExchange/dapper-dot-net 在此输入图像描述

  2. http://www.dontpaniclabs.com/blog/post/2014/05/01/speed-comparison-dapper-vs-entity-framework/

  3. ORM与传统的数据库查询,这是他们的领域?

我能理解的一件事是,手写的传统sql代码在性能上优于任何其他方法.但是我仍然想到,如果我们已经拥有最好的方法,那么ORM为什么呢?

是否只是因为我们想减少DataLayer代码?或者我们不想管理我们的数据库,并希望在我们的c#代码中编写所有内容(代码/数据优先)

为什么EF被引入,如果只有代码管理是问题那么,为什么以及我们如何妥协查询执行的性能和速度,甚至ORM都有限制.

请回答我的问题,如果需要任何编辑,请告诉我.

我唯一担心的是网站的速度和性能.

提前致谢.

c# sql orm entity-framework dapper

1
推荐指数
2
解决办法
3828
查看次数

使用外键为带有外键的表创建唯一索引

假设我有一个名为TBL_ACCOUNT的表,其中包含我的所有用户,还有一个名为TBL_EMAIL_SUBSCRIPTION的表,其中包含用户已订阅的提要。我正在尝试使其每个用户+ feed组合中只有一个条目,因此user1只能订阅一次feed1,但是user1可以同时订阅feed1和feed2。

这是我的模型的样子:

class TBL_ACCOUNT(BaseModel):
    USERNAME = CharField(unique=True)
    PASSWORD = CharField()
    EMAIL = CharField(unique=True)

class TBL_EMAIL_SUBSCRIPTION(BaseModel):
    USER = ForeignKeyField(TBL_ACCOUNT)
    FEED = CharField()

    class Meta:
        indexes = (("USER_id", "FEED", True))
Run Code Online (Sandbox Code Playgroud)

我也尝试过仅使用“ USER”作为索引,但是由于数据库仍然收到重复项,因此无法解决。

python sqlite orm peewee

1
推荐指数
1
解决办法
3238
查看次数

基于ORM的项目中的类使用

这个问题是关于像NHibernate,Subsonic,Linq2SQL等ORM的项目中的"最佳使用"场景......

所有这些工具都生成基本的实体类,一些具有属性,另一些则没有.人们使用这些类作为他们的业务类吗?或者是否有从ORM生成的类批量复制数据到手动创建的业务类?

谢谢.

.net subsonic nhibernate orm

0
推荐指数
1
解决办法
271
查看次数

适用于Oracle的最佳ORM工具,具有4000个表

我正在寻找可与Oracle和SQL Server 2005一起使用的最佳.Net ORM工具.我们有一个包含大约4000个表的Oracle数据库.我尝试使用TierDeveloper和Codesmith,当我尝试使用Oracle DB映射对象时,他们没有响应.哪个是与大型Oracle数据库一起使用的最佳ORM工具?

orm

0
推荐指数
1
解决办法
8419
查看次数


DDD最好的ORM是什么?

我更喜欢商业解决方案.所以不是NHibernate.现在我正在玩LLBLGen pro,我喜欢它,但它似乎不是DDD友好的.

.net architecture orm domain-driven-design llblgenpro

0
推荐指数
1
解决办法
1693
查看次数

用于数据库支持的集合的Java库

我正在寻找一个有效的sql支持的集合库,用于Java编程语言.

我需要做一些非常适合Collections API的数据库操作,有什么东西可以成为一个很好的桥梁,或者我必须自己动手.

java sql database collections orm

0
推荐指数
1
解决办法
309
查看次数