android greendao框架中,多表怎么插入数据和关联数据

android greendao框架中,多表怎么插入数据和关联数据,第1张

一下载GreenDao

要使用肯定要先下载他的软件包了,官网上有它的连接,对于marven和gradle环境直接到serarchmavenorg上下载jar包就好了。

下载的jar导入到工程里面就可以了,通常都是/libs目录下。

上面那个下载地址下载解压后有三个文件如下图

首先我们要创建java generator工程greendao-generator-130jar 和 freemarker-2320jar是我们创建java generator工程时生成Dao文件需要用到的(什么是我说的Dao文件,往下看就会知道) 

greendao-137jar是Android开发中需要用到的

二创建generator工程(用来生成GreenDao开发过程中需要的java文件)

(1)创建Java工程(非Android工程) 

(2)导入greenDao-generatorjar和freemarkerjar两个包。freemarker是一个用java写的模板引擎,它能够基于模板来生成文本输出。应该就是用来自动生成DAO文件的。eclipse下面就是在properties –> Java build path –> libraries下面导入jar包。 

(3)创建一个包javagreendao 

(4)创建一个类,类名为ExampleDaoGenerator,类的定义如下:

package javagreendao;

import degreenrobotdaogeneratorDaoGenerator;

import degreenrobotdaogeneratorEntity;

import degreenrobotdaogeneratorProperty;

import degreenrobotdaogeneratorSchema;

import degreenrobotdaogeneratorToMany;

/

Generates entities and DAOs for the example project DaoExample

Run it as a Java application (not Android)

@author Markus

/

public class ExampleDaoGenerator

{

   //总之main函数就执行了下面几个函数                                                                                                                                                                                                                                             

   public static void main(String[] args) throws Exception

   {

   // 参数3是数据库版本号,“comcnspeedchatgreendao”是包名,也就是说生成的Dao文件会在这个包下,可以将Schema理解为数据库上下文吧

        Schema schema = new Schema(3, "comcnspeedchatgreendao");

        //addNote() addSession() addReplay()这三个函数相当于建立了三个表,表名你都可以不用管了会自动生成

       addNote(schema);      

       addSession(schema);

       addReplay(schema);

       addCustomerOrder(schema);

   //这个是生成Dao文件的路径的位置,这个代表当前工程的上一级目录的javagreendao的src-gen文件夹里面,其实就是跟src同一级目录,所以你自己要在src同一级目录下新建一个src-gen文件夹待会要生成的文件

       new DaoGenerator()generateAll(schema, "/javagreendao/src-gen");    

   }

     //这个是一个Note表,然后后面的nodeadd是表的字段名以及属性                                                                                                                                                                                          

   private static void addNote(Schema schema)                

   {

       //"MqttChatEntity"相当于是表的类名,用MqttChatEntity生成对象就可以访问这个表属性了,也就是这个表对应了这个类,待会使用你就会明白了

       Entity note = schemaaddEntity("MqttChatEntity");    

       noteaddIdProperty()autoincrement();

       noteaddIntProperty("mode")notNull();

       noteaddStringProperty("sessionid")notNull();

       noteaddStringProperty("from")notNull();

       noteaddStringProperty("to")notNull();

       noteaddStringProperty("v_code");

       noteaddStringProperty("timestamp")notNull();

       noteaddStringProperty("platform");

       noteaddStringProperty("message");

       noteaddBooleanProperty("isread")notNull();

       noteaddLongProperty("gossipid");

       noteaddStringProperty("gossip");

       noteaddIntProperty("chattype")notNull();

       noteaddStringProperty("imagepath");

       noteaddStringProperty("base64image");

   }

   //这个是一个Session表,然后后面的nodeadd是表的字段名以及属性(这是我写的会话的一个表)

   private static void addSession(Schema schema)    

   {

       Entity note = schemaaddEntity("SessionEntity");

       noteaddIdProperty()autoincrement();

       noteaddStringProperty("sessionid")notNull()unique();

       noteaddStringProperty("from")notNull();

       noteaddStringProperty("to")notNull();

       noteaddLongProperty("gossipid")notNull();

       noteaddStringProperty("gossip");

       noteaddIntProperty("sessiontype")notNull();

       noteaddBooleanProperty("asdasd")notNull();

   }

 //这个是一个Replay表,然后后面的nodeadd是表的字段名以及属性(这是我写的回复的一个表)

   private static void addReplay(Schema schema)

   {

       //ReplayEntity对应的类名

       Entity note = schemaaddEntity("ReplayEntity");    

       noteaddIdProperty()autoincrement();

       noteaddIntProperty("mode")notNull();

       noteaddStringProperty("from")notNull();

       noteaddStringProperty("to")notNull();

       noteaddStringProperty("v_code");

       noteaddStringProperty("timestamp")notNull();

       noteaddStringProperty("platform");

       noteaddStringProperty("message");

       noteaddIntProperty("msgtype")notNull();

       noteaddBooleanProperty("isread")notNull();

   }

   //这个不用管了,照抄吧

   private static void addCustomerOrder(Schema schema)    

   {

       Entity customer = schemaaddEntity("Customer");

       customeraddIdProperty();

       customeraddStringProperty("name")notNull();

       Entity order = schemaaddEntity("Order");

       ordersetTableName("ORDERS"); // "ORDER" is a reserved keyword

       orderaddIdProperty();

       Property orderDate = orderaddDateProperty("date")getProperty();

       Property customerId = orderaddLongProperty("customerId")notNull()getProperty();

       orderaddToOne(customer, customerId);

       ToMany customerToOrders = customeraddToMany(order, customerId);

       customerToOrderssetName("orders");

       customerToOrdersorderAsc(orderDate);

   }                                                                                                                                                                                                                                                                                                              

}

1)增加表如果你自己想加一些其他的表的话,你可以自己按照addSession,addNote ,addReplay三个函数的方式加,类名、字段名可以自己随便取比如说,比我我要加一个用户表,字段包括name,age,sex三个,我可以这样做

   private static void addUser(Schema schema)  

   {

       Entity note = schemaaddEntity("UserEntity");    

       noteaddIdProperty()autoincrement();

       noteaddStringProperty("name")notNull();

       noteaddIntProperty("age")notNull();

       //true代表男,false代表女

       noteaddBooleanProperty("sex")notNull();    

   }

然后在main函数里面做如下调用

   public static void main(String[] args) throws Exception

   {

       Schema schema = new Schema(3, "comcnspeedchatgreendao");    

       addNote(schema);        

       addSession(schema);

       addReplay(schema);

       addUser(schema);

       addCustomerOrder(schema);

       new DaoGenerator()generateAll(schema, "/javagreendao/src-gen");

   }

2)删除表当然一些不需要的表你可以不用,删掉就行,比如说你不须要addReplay,你就在main函数里面别调用addReplay(schema)就行

总之呢,这就是一个基于greenDao-generatorjar和freemarkerjar两个包的java工程

然后运行该工程,控制台打印出如下结果:

greenDAO Generator Copyright 2011-2013 Markus Junginger,

greenrobotde Licensed under GPL V3 This program comes with

ABSOLUTELY NO WARRANTY Processing schema version 3… Written

/home/csm/workspace/javagreendao/src-gen/com/cn/speedchat/greendao/MqttChatEntityDaojava

Written

/home/csm/workspace/javagreendao/src-gen/com/cn/speedchat/greendao/MqttChatEntityjava

Written

/home/csm/workspace/javagreendao/src-gen/com/cn/speedchat/greendao/SessionEntityDaojava

Written

/home/csm/workspace/javagreendao/src-gen/com/cn/speedchat/greendao/SessionEntityjava

Written

/home/csm/workspace/javagreendao/src-gen/com/cn/speedchat/greendao/ReplayEntityDaojava

Written

/home/csm/workspace/javagreendao/src-gen/com/cn/speedchat/greendao/ReplayEntityjava

Written

/home/csm/workspace/javagreendao/src-gen/com/cn/speedchat/greendao/CustomerDaojava

Written

/home/csm/workspace/javagreendao/src-gen/com/cn/speedchat/greendao/Customerjava

Written

/home/csm/workspace/javagreendao/src-gen/com/cn/speedchat/greendao/OrderDaojava

Written

/home/csm/workspace/javagreendao/src-gen/com/cn/speedchat/greendao/Orderjava

Written

/home/csm/workspace/javagreendao/src-gen/com/cn/speedchat/greendao/DaoMasterjava

Written

/home/csm/workspace/javagreendao/src-gen/com/cn/speedchat/greendao/DaoSessionjava

Processed 5 entities in 189ms

这代表成功的生成了Dao文件,然后我们按F5刷新该工程,在查看src-gen目录文件,自动生成了很多java文件,这就是我们要的,我这里截图给大家看

但是有很多错误是不是,没关系,这个工程识别不了这些文件,这些文件是基于greendao-137jar包的,是Android工程里面要用到的。先不管这个java工程了。

博凌科为的产品都挺好的,很多实验室都在用,这个品牌挺值得信赖的!

产品简介

RealMasterMix 是一种使用SYBR Green 进行Real Time PCR扩增反应的全新预混系统。RealMasterMix 中包含了优化配比的dNTP、增强剂、稳定剂等,以提高产物特异性和反应灵敏度。同时,还加入了ROX 作为内参染料,以使Real Time PCR 中的荧光达到最优状态。

RealMasterMix 采用全新的Hotmaster Taq DNA 聚合酶,该酶不同于一般Hot-start 酶之处在于,一般的Hot-start 酶只在第一步温度升高之前封闭酶的活性,而Hotmaster Taq DNA 聚合酶是利用抑制剂通过温度调节方式封闭Hotmaster Taq DNA聚合酶的底物结合位点,温度低于40℃时,形成非活性的酶-抑制剂复合物,当温度升高至引物特异性的退火温度时,结合平衡向模板-特异性引物复合物形成方向移动,因此最大限度的减少PCR扩增全程中的非特异性扩增产物产生,大大提高了荧光定量PCR反应的精确性。

产品特点

■ 试剂盒中使用了改良后的Hotmaster Taq Polymerase,具有高扩增效率,高扩增灵敏度,高扩增特异性的特点。

■ 独特的Mg2+ 自动调整系统,能够随时保证为PCR提供最佳的Mg2+ 浓度。

■ 独特配制的SYBR Solution可满足不同类型的荧光定量实验需求。

产品应用

该试剂盒确保DNA或cDNA模板的准确定量,适用于各种类型荧光定量PCR 仪。

保存条件: -20℃避光保存

Only by obeying nature can we defeat nature

只有服从大自然,才能战胜大自然。

Only when trees are green can the earth have a pulse

树木拥有绿色,地球才有脉搏。

The earth is my home, and greening depends on everyone

地球是我家,绿化靠大家。

重点词汇

服从 obey ; submit to ; be subordinated to ; abide

大自然 nature

战胜 defeat ; triumph over ; vanquish ; overcome

树木 arbor ; trees

绿色 green

地球 the earth ; the globe

脉搏 pulse ; sphygmus

我家 my home/house/family

绿化 make green by planting trees, flowers, etc ; afforest ; green

大家 great master ; authority

没有问题,如果是浓度较高的母液建议稀释分装后冷冻保存,即便是稀释过的室温过夜也问题不大。但是注意尽量避免反复冻融,这个比保质期内持续放在4度更容易导致降解。我的sybr green就从来没有冷冻保存过,都是4度,但是sybr green的PCR master mix就是另一回事了。

  Simple Plan目前为止已获5届mmva奖最佳乐队

  到目前为止,共出了4张专辑

  1:<<No Pads, No Helmets…Just Balls>>

  发行日期:2002年

  专辑曲目:

  01 I'd Do Anything

  02 The Worst Day Ever

  03 You Don't Mean Anything

  04 I'm Just a Kid

  05 When I'm With You

  06 Meet You There

  07 Addicted

  08 My Alien

  09 God Must Hate Me

  10 I Won't Be There

  11 One Day

  12 Perfect

  2:<<Still Not Getting Any>>

  发行日期:2004年10月20日

  专辑曲目:

  1 Shut Up!

  2 Welcome To My Life (推荐推荐!)

  3 Perfect World

  4 Thank You

  5 Me Against The World

  6 Crazy

  7 Jump

  8 Everytime

  9 Promise

  10 One

  11 Untitled

  12Perfect(Live)

  第三张:MTVHardRockLive

  发行日期:2005年10月3日

  专辑曲目:

  01 Shut Up

  02 Jump

  03 Worst Day Ever

  04 Addicted

  05 Me Against The World

  06 Crazy

  07 God Must Hate Me

  08 Thank You

  09 Welcome To My Life

  10 I'm Just A Kid

  11 I'd Do Anything

  12 Untitled

  13 Perfect

  14 Crazy (Acoustic Version)

  07年10月29日,SP发布新单曲"When I'm Gone"

  第4张专辑<<Simple Plan>>,同名专辑

  发行日期:08年2月12日

  阔别四年之后Simple Plan终于带来了他们的最新同名专辑Simple Plan,对于这张专辑,从单曲When I'm Gone发出之后变受到极大的关注,讨论的最多的就是SP的改变,到底SP的改变是否能成功,时间会证明的。Simple Plan被作为专辑名字似乎也预示着SP已经开始一段新的音乐旅程。

  1- When I'm Gone

  2- Take My Hand

  3- The End

  4- Your Love Is A Lie

  5- Save You

  6- Generation

  7- Time To Say Goodbye

  8- I Can Wait Forever

  9- Holding On

  10- No Love

  11- What If

  12 When I'm Gone (Acoustic Version Bonus tracks)

  13 Running Out of Time (Bonus tracks)

  专辑

  39/Smooth(1990)

  Kerplunk(1992)

  Dookie(1994)

  Insomniac(1995)

  Nimrod(1997)

  Warning(200010)

  American Idiot(200409)

  EP

  欣赏两首MV吧,你可以看到主唱Ian Watkins的招牌动作——甩话筒。

  Rooftops

  Can't Catch Tomorrow

  Everyday Combat

  A Town Called Hypocrisy

  For All These Times Kid, For All These Times

  录音室专辑:

  Kill 'Em All (1983)

  Ride the Lightning (1984)

  Master of Puppets (1986)

  And Justice for All (1988)

  Metallica (1991)

  Load (1996)

  ReLoad (1997)

  St Anger (2003)

  Death Magnetic (2008)

  现场专辑:

  Live Shit: Binge & Purge (1993)

  S&M (1999)

  翻唱专辑:

  Garage Inc (1998)

  EP:

  The $598 EP: Garage Days Re-Revisited (1987)

  Some Kind of Monster(2004)

  小样:

  Hit the Lights (1982)

  Ron McGovney's '82 Garage Demo (1982)

  Power Metal demo (1982)

  No Life 'Til Leather (1982)

  Metal Up Your Ass (1982)

  Horsemen of the Apocalypse (1983)

  Megaforce demo (1983)

  单曲:

  "Whiplash"

  "Jump in the Fire"

  "Fade to Black"

  "Creeping Death"

  "For Whom the Bell Tolls"

  "Master of Puppets"

  "Battery"

  "Welcome Home (Sanitarium)"

  "Eye of the Beholder"

  "Harvester of Sorrow"

  "And Justice for All"

  "One" "Enter Sandman"

  "Don't Tread on Me"

  "The Unforgiven"

  "Nothing Else Matters"

  "Wherever I May Roam"

  "Sad But True"

  "Until It Sleeps"

  "Ain't My Bitch"

  "Hero of the Day"

  "Mama Said"

  "King Nothing"

  "Bleeding Me"

  "The Memory Remains"

  "The Unforgiven II"

  "Fuel"

  "Better Than You"

  "Turn the Page"

  "No Leaf Clover"

  "I Disappear"

  "St Anger"

  "Frantic"

  "The Unnamed Feeling"

  "Some Kind of Monster"

  The Day That Never Comes"

  "My Apocalypse"

  "Cyanide"

  DVD:

  Cliff 'em All (1987)

  2 of One (1989)

  A Year and a Half in the Life of Metallica (1992)

  Live Shit: Binge & Purge (1993)

  Cunning Stunts (1998)

  S&M (1999)

  Classic Albums: Metallica - The Black Album (2001)

  Some Kind of Monster (2005)

  The Videos 1989-2004 (2006)

  向Metallica致敬:

  Plays Metallica by Four Cellos by Apocalyptica

  Matenlos a Todos (Tributo Argentino a Metallica)

  Metallic Assault

  Moskvallica: A Russian Tribute to Metallica)

  Tribute to Metallica by Die Krupps

  The Tribute to the Four Horsemen

  "Say Your Prayers, Little One" The String Quartet Tribute to Metallica

  The Scorched Earth Orchestra plays Metallica's Master of Puppets (The Orchestral Tribute)

  A Punk Tribute to Metallica

  Metallic Attack: The Ultimate Tribute to Metallica

  Dream Theater - Master of Metallica

  Fade to Bluegrass: The Bluegrass Tribute to Metallica

  Fade to Bluegrass: The Bluegrass Tribute to Metallica, Vol 2

  Metal Militia: A Tribute to Metallica (Vol 1, 2 & 3)

  Blackest Album: An Industrial Tribute to Metallica (Vol 1, 2 & 3)

  Hip-Hop Tribute to Metallica

  Beatallica

  Master of Puppets: Remastered

  Nothing Else Matters (cover) by Bif Naked

  Overload

  Overload, Vol 2

  A Metal Tribute to Metallica

  Rockabye Baby! Lullaby Renditions of Metallica

  MTV Icon: Metallica

  Broken Promises - Element Eighty

  试听及歌词:http://wwwsongtastecom/song/43839/

  下载百度有:http://mp3baiducom/mtn=baidump3&ct=134217728&lm=-1&word=Broken+Promises+Element+Eighty

EVERGREEN

长荣海运:

张荣发40年心血的结晶,管理十分混乱,咎其原因是因为张荣发老婆太多,老婆多了儿子自然多,张大老板有6个儿子,2个女儿,这么多儿女是要安排工作的,可是除了二儿子没有一个着调的,儿女之间互相倾轧,十分惨烈。长荣是股份公司,张荣发控股,但是还有他人股份,当年航运市场最低迷的时候,张荣发拿自己的钱注册了立荣,以防长荣忽然倒下自己没有退身之所。但后来市场越来越好,长荣越来越好,于是就让长荣高价收购了立荣,张荣发自己大赚一笔。后来为了经营两岸直航,继续收购意邮,以欧洲公司的名义作直航。去年又成立HASU MARINE(绝对内幕),因为2006年长荣运力将增长40%,要分散风险。

前些日子,长荣的船接危险品出了事,哎

惨了类, 所以,现在大家都看的到了,一般危险品都不走长荣了,只有象MSC这样的垃圾船接的多,据港区配载说,危险品都是放在最上面,万一有出事的苗头,马上掀下海,呵呵,船公司可是一点责任没有, 大家有没有看到MASTER 提单后面密密麻麻的条款没有, 很多事情船公司都是免责的

转载

博凌科为的2 x SYBR Green qPCR Mix (荧光染料法)是采用SYBR Green I嵌合荧光法进行Real Time PCR的专用试剂。已经将热启动HotMaster Taq DNA聚合酶、dNTP、特殊稳定剂、优化的反应缓冲液、BSA和SYBR Green I等试剂预混成一种适合Real Time PCR反应检测用2×Premix Type试剂,具有灵敏度高、特异性强、稳定性好等特点。使用时只需加入模板和引物和水,便可在宽广的定量区域内得到良好的标准曲线,对目的基因进行准确定量检测,重复性好,可信度高。本品采用全新的Hotmaster Taq DNA 聚合酶,该酶不同于一般Hot-start 酶之处在于,一般的Hot-start 酶只在第一步温度升高之前封闭酶的活性,而Hotmaster Taq DNA 聚合酶是利用抑制剂通过温度调节方式封闭Hotmaster Taq DNA聚合酶的底物结合位点,温度低于40℃时,形成非活性的酶-抑制剂复合物,当温度升高至引物特异性的退火温度时,结合平衡向模板-特异性引物复合物形成方向移动,因此最大限度的减少PCR扩增全程中的非特异性扩增产物产生,大大提高了荧光定量PCR反应的精确性。

注意事项:

1 本制品不含内参染料ROX,客户并根据qPCR仪器技术指导决定是否需要加ROX内参染料,用于消除信号本底以及校正孔与孔之间产生的荧光信号误差,配套ROX产品货号为PC38 Rox Reference Dye。

2 本制品含SYBR® Green I 强光下易分解,降低敏感度,使用时避免长时间强光照射本制品。

3 建议在冰上配制PCR反应液,再放入PCR仪器中扩增。可以提高扩增特异性,减少背景。

4 本制品含有4 mM MgCl2(反应体系终浓度是2 mM Mg2+),可用25mM MgCl2 优化Mg2+浓度。

欢迎分享,转载请注明来源:浪漫分享网

原文地址:https://hunlipic.com/meirong/11307041.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-11-27
下一篇2023-11-27

发表评论

登录后才能评论

评论列表(0条)

    保存