spring data question ``` interface InserterPacket1...
# spring
x
spring data question
Copy code
interface InserterPacket100hz {
    fun myInsertAll(list: Collection<Packet100hz> )
}
interface Packet100hzRepo: CrudRepository<Packet100hz, RFID>, InserterPacket100hz

@Repository
internal class Packet100HzInsertImpl(private val jdbc: JdbcTemplate): InserterPacket100hz {

    override fun myInsertAll(list: Collection<Packet100hz>) {
        var sql = "INSERT INTO packet_100hz_secure (rfid, pressure_signal, uo_pressure, chamber_pressure, ultrasonic_signal, \"timestamp\") VALUES "
        for (packet100hz in list) {
            // 6 cols
            sql += "(?, ?, ?, ?, ?, ?)\n" // maybe should use string builder
        }
        val inserts = list.flatMap {
            listOf(
                it.rfid.rfid,
                it.pressureSignal,
                it.uoPressure,
                it.chamberPressure,
                it.ultrasonicSignal,
                it.rfid.timestamp
            )
        }.toTypedArray()
        jdbc.update( sql, inserts )
    }
}
Copy code
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property myInsertAll found for type Packet100hz!
… well no duh spring… trying to do a custom repository implementation, anyone know what I’m doing wrong?
t
@xenoterracide
interface Packet100hzRepo: CrudRepository<Packet100hz, RFID>, InserterPacket100hz
shouldnt this have the
@Repository
annotation?
also i do not think you need the
@Component
annotation 🤔
x
tried that same error 😕
t
and removed the component annotation?
oh no no
sec
Copy code
interface InserterPacket100hz {
    fun myInsertAll(list: Collection<Packet100hz> )
}

@Repository
interface Packet100hzRepo: CrudRepository<Packet100hz, RFID>, InserterPacket100hz

internal class Packet100HzInsertImpl(private val jdbc: JdbcTemplate): InserterPacket100hz {

    override fun myInsertAll(list: Collection<Packet100hz>) {
        var sql = "INSERT INTO packet_100hz_secure (rfid, pressure_signal, uo_pressure, chamber_pressure, ultrasonic_signal, \"timestamp\") VALUES "
        for (packet100hz in list) {
            // 6 cols
            sql += "(?, ?, ?, ?, ?, ?)\n" // maybe should use string builder
        }
        val inserts = list.flatMap {
            listOf(
                it.rfid.rfid,
                it.pressureSignal,
                it.uoPressure,
                it.chamberPressure,
                it.ultrasonicSignal,
                it.rfid.timestamp
            )
        }.toTypedArray()
        jdbc.update( sql, inserts )
    }
}
try this @xenoterracide
also you can try removing the
internal
keyword…but i am not 100% sure on that one
x
tried both of those things 😕
and splitting the file
looks like it has to be InterfaceNameImpl exactly
and not a bean
x
@corneil yeah I saw that, do you know if it does the multi-value insert like I’m doing? or is it just doing like 100 inserts in a cleaner way?
c
batchUpdate can be used to insert many rows in a batch. It is very efficient and doesn't rely on concatenating a statement and ending up with 100s or 1000s of parameters.