• dave08

    dave08

    4 years ago
    Is there a way to retreive only an sql statement w/o running it (to be executed w/ another library...)?
    dave08
    1 replies
    Copy to Clipboard
  • n

    nekoinemo

    4 years ago
    Hi. I feel like i asked this already long time ago, but: how do i create multi-column PK (i.e. for many-to-many join tables)? do i just call primaryKey() on all required columns? ... It does.
    n
    1 replies
    Copy to Clipboard
  • w

    wouterdoeland

    4 years ago
    Hi! I'm getting this very annoying exception:
    Caused by: java.sql.SQLException: Multiple primary key defined
    Query is: ALTER TABLE Clans MODIFY COLUMN id INT AUTO_INCREMENT PRIMARY KEY
    Does anyone know why this is happening? This happens everytime I run
    SchemaUtils.createMissingTablesAndColumns(Clans)
    with Clans or with any other table.
    w
    tapac
    3 replies
    Copy to Clipboard
  • oshai

    oshai

    4 years ago
    @tapac - after upgrading to 0.10.1 the following do not compile:
    transaction(statement)
    oshai
    tapac
    8 replies
    Copy to Clipboard
  • tapac

    tapac

    4 years ago
    In your case you should use
    insertAndGetId
    When you write
    insert[id]
    you try to get value related to "expression" from resultSet. It can be null if, for example, it wasn't inserted, that's why column type (not-nullable) doesn't make sense.
    tapac
    z
    4 replies
    Copy to Clipboard
  • z

    ziad

    4 years ago
    This is what I went for, is there a cleaner or more idiomatic way to do it?
    return transaction {
               //Check if a user with this device id exists       
                val userIdEntity = Users.select {
                    Users.deviceId eq deviceId
                }.map { it[Users.id] }.firstOrNull()
    
                //Assign the user id 
                val userId =
                        if(userIdEntity != null) {
                            userIdEntity.value
                        } else
                        {
                            Users.insertAndGetId {
                            //...
                            }.value
                        }
            }
    z
    1 replies
    Copy to Clipboard
  • avolkmann

    avolkmann

    4 years ago
    Is there a way to select isNull() ?
    avolkmann
    tapac
    2 replies
    Copy to Clipboard
  • n

    niteesh

    4 years ago
    I am able to achieve a connection pool to my database using SpringTransactionManager(dataSource) . But as my dao layer use transaction { } blocks, I get the IllegalStateException: Already value for key bound to thread [main]
    n
    tapac
    6 replies
    Copy to Clipboard
  • m

    mattiascrofani

    4 years ago
    Hello there. Real noob here with kotlin and exposed. I'm trying to run a simple join but clearly I'm missing something obvious so I was trying to recreate what I read on the wiki. AccessToken.idStaff and Staff.id are both int. The exception says that "Cannot join as there is no matching primary key/ foreign key pair and constraint missing". Isn't that "select" the condition for the join?
    (AccessToken innerJoin Staff).slice(Staff.id, Staff.userName).select {AccessToken.idStaff eq Staff.id}
    m
    2 replies
    Copy to Clipboard
  • b

    betterclever

    4 years ago
    Is there any way to map them to Inspection Entity object directly?
    b
    1 replies
    Copy to Clipboard