<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/inline-classes-make-great-database-ids-wmglmybti" -->

---
title: Inline Classes Make Great Database IDs | daily.dev
description: Kotlin 1.3&#x27;s inline classes can be used as type-safe wrappers for database IDs, preventing common bugs like passing a payment ID where a customer ID is...
canonical: https://daily.dev/posts/inline-classes-make-great-database-ids-wmglmybti
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Inline Classes Make Great Database IDs | daily.dev
og:description: Kotlin 1.3&#x27;s inline classes can be used as type-safe wrappers for database IDs, preventing common bugs like passing a payment ID where a customer ID is...
og:url: https://daily.dev/posts/inline-classes-make-great-database-ids-wmglmybti
og:image: https://api.daily.dev/og/posts/wmglMybtI.png
og:image:alt: Inline Classes Make Great Database IDs
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Inline Classes Make Great Database IDs

**[Jake Wharton](https://daily.dev/sources/jakewharton)** · 3 min read · 0 upvotes · 0 comments

## Summary

Kotlin 1.3's inline classes can be used as type-safe wrappers for database IDs, preventing common bugs like passing a payment ID where a customer ID is expected. By defining inline classes (e.g., CustomerId, PaymentId) and integrating them with SQLDelight's schema definitions, the compiler catches ID mix-ups at compile time rather than silently returning wrong results at runtime. The approach is low-overhead since SQLDelight auto-generates typed model objects and query functions, making the safety essentially free after the initial setup.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://jakewharton.com/inline-classes-make-great-database-ids>

## Similar posts on daily.dev

- [Kotlin Value Classes: Stop Wrapping Everything in Regular Classes](https://daily.dev/posts/kotlin-value-classes-stop-wrapping-everything-in-regular-classes-dynlkkeym) · ProAndroidDev · 4 upvotes · 0 comments
- [Kotlin Value Classes: Stop Wrapping Everything in Regular Classes](https://daily.dev/posts/kotlin-value-classes-stop-wrapping-everything-in-regular-classes-xcwqte7pp) · droidcon · 1 upvotes · 0 comments
- [How to Avoid Common Pitfalls With JPA and Kotlin](https://daily.dev/posts/how-to-avoid-common-pitfalls-with-jpa-and-kotlin-hgchpvpwb) · Kotlin · 1 upvotes · 0 comments

---

Tags: [#backend](https://daily.dev/tags/backend), [#kotlin](https://daily.dev/tags/kotlin)

[View this post on daily.dev](https://daily.dev/posts/inline-classes-make-great-database-ids-wmglmybti)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Inline Classes Make Great Database IDs","url":"https://daily.dev/posts/inline-classes-make-great-database-ids-wmglmybti","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/inline-classes-make-great-database-ids-wmglmybti"},"datePublished":"2026-07-05T07:13:52.701Z","dateModified":"2026-07-05T07:16:56.052Z","description":"Kotlin 1.3's inline classes can be used as type-safe wrappers for database IDs, preventing common bugs like passing a payment ID where a customer ID is...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/783b359bc344ce8763770516ac461830?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/783b359bc344ce8763770516ac461830?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Jake Wharton","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Jake Wharton","logo":"https://media.daily.dev/image/upload/logos/placeholder.jpg","url":"https://daily.dev/sources/jakewharton"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/inline-classes-make-great-database-ids-wmglmybti","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"backend,kotlin","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Jake Wharton","item":"https://daily.dev/sources/jakewharton"},{"@type":"ListItem","position":3,"name":"Inline Classes Make Great Database IDs"}]}
```

