title: How to add prefix index to MySQL using JPA?
body: <p>I used JPA to operate the MySQL database in springboot. I tried to add a prefix index to the name column, but failed. I wonder if this can be done with JPA. Here is my code</p>
  <pre><code>@Entity
  @Table(name = &quot;user_setting&quot;, indexes = [Index(columnList = &quot;name&quot;)])
  class UserSettingTable {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = &quot;id&quot;)
      var id: Int = 0
  
      @Column(name = &quot;name&quot;, length = 256, nullable = false)
      var domain: String = &quot;&quot;
  }
  </code></pre>
  <p>I tried to create it like this, but it didn't work.</p>
  <pre><code>@Entity
  @Table(name = &quot;user_setting&quot;, indexes = [Index(columnList = &quot;name(50)&quot;)])
  class UserSettingTable {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = &quot;id&quot;)
      var id: Int = 0
  
      @Column(name = &quot;name&quot;, length = 256, nullable = false)
      var domain: String = &quot;&quot;
  }
  </code></pre>
  <p>Additional information:</p>
  <pre><code>&lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;2.3.2.RELEASE&lt;/version&gt;
      &lt;relativePath/&gt;
  &lt;/parent&gt;
  </code></pre>