我已经创建了使用的现有数据库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) 我exercise和muscle模型之间有很多很多关联.我删除单一关联
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) 有这个课程:
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) 我真的很沮丧地搜索这个答案,哪个更好 - 传统的System.Data.SqlClient方法或使用任何ORM,如EF或Dapper我通过许多链接看到了很多比较,有些是:
我能理解的一件事是,手写的传统sql代码在性能上优于任何其他方法.但是我仍然想到,如果我们已经拥有最好的方法,那么ORM为什么呢?
是否只是因为我们想减少DataLayer代码?或者我们不想管理我们的数据库,并希望在我们的c#代码中编写所有内容(代码/数据优先)
为什么EF被引入,如果只有代码管理是问题那么,为什么以及我们如何妥协查询执行的性能和速度,甚至ORM都有限制.
请回答我的问题,如果需要任何编辑,请告诉我.
我唯一担心的是网站的速度和性能.
提前致谢.
假设我有一个名为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”作为索引,但是由于数据库仍然收到重复项,因此无法解决。
这个问题是关于像NHibernate,Subsonic,Linq2SQL等ORM的项目中的"最佳使用"场景......
所有这些工具都生成基本的实体类,一些具有属性,另一些则没有.人们使用这些类作为他们的业务类吗?或者是否有从ORM生成的类批量复制数据到手动创建的业务类?
谢谢.
我正在寻找可与Oracle和SQL Server 2005一起使用的最佳.Net ORM工具.我们有一个包含大约4000个表的Oracle数据库.我尝试使用TierDeveloper和Codesmith,当我尝试使用Oracle DB映射对象时,他们没有响应.哪个是与大型Oracle数据库一起使用的最佳ORM工具?
重复:
对于大型ASP.NET应用程序,实体框架或NHibernate,您会推荐什么?您认为这两种技术的优缺点是什么?
我更喜欢商业解决方案.所以不是NHibernate.现在我正在玩LLBLGen pro,我喜欢它,但它似乎不是DDD友好的.
我正在寻找一个有效的sql支持的集合库,用于Java编程语言.
我需要做一些非常适合Collections API的数据库操作,有什么东西可以成为一个很好的桥梁,或者我必须自己动手.
orm ×10
java ×3
.net ×2
nhibernate ×2
sql ×2
sqlite ×2
android ×1
architecture ×1
asp.net ×1
c# ×1
collections ×1
dapper ×1
database ×1
hibernate ×1
hql ×1
jpa ×1
llblgenpro ×1
mysql ×1
node.js ×1
peewee ×1
python ×1
sequelize.js ×1
subsonic ×1
sugarorm ×1