Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. CREATE DATABASE `test_db` /*!40100 DEFAULT CHARACTER SET utf8 */;
  2.  
  3. CREATE TABLE `atable` (
  4. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  5. `shortText` varchar(255) DEFAULT NULL,
  6. `longText` blob,
  7. PRIMARY KEY (`id`),
  8. UNIQUE KEY `id` (`id`)
  9. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
  10.  
  11. @Entity(name = "atable")
  12. public class AClass{
  13. @Id
  14. @Column(name = "id", unique = true)
  15. @GeneratedValue
  16. Long id;
  17. @Column
  18. private String shortText; //also exists setter and getter, of course
  19. private byte[] longText;
  20. public void setLongText(String s){this.longText = (s!=null)?s.getBytes():null;}
  21. public String getLongText(){return this.longText!=null?new String(longText):null;}
  22. }
  23.  
  24. jdbc:mysql://localhost:3306/app_db?useUnicode=true&characterEncoding=utf8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement