You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.6 KiB
54 lines
1.6 KiB
package rest; |
|
|
|
|
|
// import dto.ConnectDB; |
|
// import dto.Scan; |
|
|
|
import org.hibernate.Session; |
|
import org.hibernate.SessionFactory; |
|
import org.hibernate.Transaction; |
|
import org.hibernate.boot.Metadata; |
|
import org.hibernate.boot.MetadataSources; |
|
import org.hibernate.boot.registry.StandardServiceRegistry; |
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder; |
|
|
|
import javax.ws.rs.GET; |
|
import javax.ws.rs.Path; |
|
// import org.hibernate.EntityManager; |
|
|
|
|
|
@Path("/storeData") |
|
public class StoreData { |
|
|
|
//all of these need cleaning up to be a more sensible soution |
|
// @RestClient |
|
// CreateScanService createScanService; |
|
|
|
@GET |
|
public void Store() { |
|
System.out.println("hmm"); |
|
|
|
//Create typesafe ServiceRegistry object |
|
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().configure("hibernate.cfg.xml").build(); |
|
|
|
Metadata meta = new MetadataSources(ssr).getMetadataBuilder().build(); |
|
|
|
SessionFactory factory = meta.getSessionFactoryBuilder().build(); |
|
Session session = factory.openSession(); |
|
Transaction t = session.beginTransaction(); |
|
System.out.println("i assume we fail before here?"); |
|
Scan e1=new Scan(); |
|
e1.setScanId(2); |
|
e1.setProductId("1"); |
|
e1.setEventId("Chawla"); |
|
e1.setIsManagedService("aa"); |
|
e1.setComponentList("aaa"); |
|
|
|
session.save(e1); |
|
t.commit(); |
|
System.out.println("successfully saved"); |
|
factory.close(); |
|
session.close(); |
|
|
|
} |
|
} |