<commit_before>package com.example.greendao;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.example.greendao.model.Author;
import com.example.greendao.model.AuthorDao;
import com.example.greendao.model.Customer;
import com.example.greendao.model.CustomerDao;
import com.example.greendao.model.Note;
import com.example.greendao.model.NoteDao;
import com.example.greendao.model.Order;
import com.example.greendao.model.OrderDao;

import java.util.Date;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // warning: should never do this on the main thread, doing this here for brevity
        insertAndUpdateAuthor();
        insertAndLoadNote();
        insertAndUpdateToMany();
    }

    private void insertAndUpdateAuthor() {
        AuthorDao authorDao = ExampleApp.getDaoSession(this).getAuthorDao();
        authorDao.deleteAll();

        Author author = new Author();
        author.setUserId("author1");
        authorDao.insert(author);

        // simulate adding updated author: need to resolve user id conflict by replacing row
        author = new Author();
        author.setUserId("author1");
        authorDao.insertOrReplace(author);

        List<Author> results = authorDao.queryBuilder()
                .where(AuthorDao.Properties.UserId.eq("author1"))
                .list();
        Author authorLoaded = results.get(0);
    }

    private void insertAndLoadNote() {
        NoteDao noteDao = ExampleApp.getDaoSession(this).getNoteDao();
        noteDao.deleteAll();

        Note note = new Note();
        note.setText("some text");
        note.setDate(new Date());
        noteDao.insert(note);

        note.setText("some new text");<commit_msg>Can use unique to get author.<commit_after>package com.example.greendao;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.example.greendao.model.Author;
import com.example.greendao.model.AuthorDao;
import com.example.greendao.model.Customer;
import com.example.greendao.model.CustomerDao;
import com.example.greendao.model.Note;
import com.example.greendao.model.NoteDao;
import com.example.greendao.model.Order;
import com.example.greendao.model.OrderDao;

import java.util.Date;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // warning: should never do this on the main thread, doing this here for brevity
        insertAndUpdateAuthor();
        insertAndLoadNote();
        insertAndUpdateToMany();
    }

    private void insertAndUpdateAuthor() {
        AuthorDao authorDao = ExampleApp.getDaoSession(this).getAuthorDao();
        authorDao.deleteAll();

        Author author = new Author();
        author.setUserId("author1");
        authorDao.insert(author);

        // simulate adding updated author: need to resolve user id conflict by replacing row
        author = new Author();
        author.setUserId("author1");
        authorDao.insertOrReplace(author);

        Author authorLoaded = authorDao.queryBuilder()
                .where(AuthorDao.Properties.UserId.eq("author1"))
                .unique();
    }

    private void insertAndLoadNote() {
        NoteDao noteDao = ExampleApp.getDaoSession(this).getNoteDao();
        noteDao.deleteAll();

        Note note = new Note();
        note.setText("some text");
        note.setDate(new Date());
        noteDao.insert(note);

        note.setText("some new text");
{'fraction_non_alphanumeric': 0.10418310970797158, 'fraction_numerical': 0.0023677979479084454, 'mean_word_length': 3.159737417943107, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5628685', 'n_tokens_mistral': 1052, 'n_tokens_neox': 1065, 'n_words': 227}