2

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 2

5

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.

Sign up to request clarification or add additional context in comments.

5 Comments

if I am doing it standlone, is there any difference? within the code or none?
The only difference is how you obtain the EntityManager, as @SplinterReality showed you. The Entity manager is the object that will help you persist your objects.
The POJO (Plain Old Java Object), that you want to persist, and as such, you should annotate it with @Entity at the class level... it will all clear up as you work through the tutorials...
with hibernate, the details in my setters and getters will be in the database?????
Once you add an @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).
0

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();

1 Comment

I don't have any idea about Persistence API , I don't know how to use them I have no idea at all

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.