$ oct generate kt --help
Option | Env. Variable | Description |
---|---|---|
-i , --input |
OCTOPUS_INPUT |
Octopus schema file to read |
-o , --output |
OCTOPUS_OUTPUT |
Target file or directory |
-a , --annotation |
OCTOPUS_ANNOTATION |
Custom Entity class annotation. Format: {group1}:{annotations1}[,{group2}:{annotations2}]... |
-g , --groups |
OCTOPUS_GROUPS |
Table groups to generate. Set multiple groups with comma( , ) separated. |
-e , --idEntity |
OCTOPUS_ID_ENTITY |
Interface NAME with id field |
-p , --package |
OCTOPUS_PACKAGE |
Entity class package name |
-f , --prefix |
OCTOPUS_PREFIX |
Class name prefix. Format: {group1}:{prefix1}[,{group2}:{prefix2}]... |
-l , --relation |
OCTOPUS_RELATION |
Virtual relation annotation type. Available values: VRelation |
-d , --removePrefix |
OCTOPUS_REMOVE_PREFIX |
Prefixes to remove from class name. Set multiple prefixes with comma( , ) separated. |
-r , --reposPackage |
OCTOPUS_REPOS_PACKAGE |
Repository class package name. Skip if not set. |
-q , --uniqueNameSuffix |
OCTOPUS_UNIQUE_NAME_SUFFIX |
Unique constraint name suffix |
-u , --useUTC |
OCTOPUS_USE_UTC |
Set flag to use UTC for audit columns (created_at , updated_at ).Default: false |
$ oct generate kt \
--input examples/user.json \
--output output/ \
--package octopus.entity \
--reposPackage octopus.repos \
--useUTC
Generated *.kt
files:
package octopus.entity
import javax.persistence.*
@Entity
@Table(name="group", uniqueConstraints = [
UniqueConstraint(name = "group", columnNames = ["name"])
])
data class UserGroup(
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(nullable = false)
var id: Long = 0L,
@Column(nullable = false, length = 40)
var name: String = ""
)
package octopus.entity
import javax.persistence.*
@Entity
@Table(name="user", uniqueConstraints = [
UniqueConstraint(name = "user", columnNames = ["name"])
])
data class User(
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(nullable = false)
var id: Long = 0L,
@Column(nullable = false, length = 40)
var name: String = "",
var groupId: Long?
)
package octopus.repos
import octopus.entity.*
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository
@Repository
interface UserGroupRepository : JpaRepository<UserGroup, Long>
package octopus.repos
import octopus.entity.*
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository
@Repository
interface UserRepository : JpaRepository<User, Long>