I am going to make a database where I need to make use of mapping, (THIS IS NOT JAVA EE) I am speaking of JavaSE only not EE, I was wondering how would I implement these class I made? (User,Contactinformation,Employee,FinanceTeam,SystemAdmin) how will I transfer the datas of these objects into the database? and how does mapping work? a BASIC Database tutorial will HELP me a lot, Thanks Btw if you are curious I am using MySQL for my database
2 Answers
You need an ORM (Object-Relational Mapping) and Hibernate is the most commonly used, Hibernate can also be used standalone, not only in Java EE environment.
JavaBrains video tutorial is 34 lessons, well explained and easy to understand, I highly recommend you. The author is not a native English speaker, so if you look past the accent, it's a great content.
5 Comments
@Entity annotation on the class and an @Id annotation on the primary key field, or getter, the other fields or getters will be persisted, except those annotated with @Transient (or preceded with the transient keyword).Why not use a JPA like Hibernate or EclipseLink? They work just fine in a J2SE environment, the only difference is how you obtain the EntityManager reference. (By creating the EntityManagerFactory directly as opposed to Container Managed Injection)
factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
EntityManager em = factory.createEntityManager();