- This topic has 5 replies, 2 voices, and was last updated 16 years, 5 months ago by Loyal Water.
-
AuthorPosts
-
jaladanki_sunilMemberhi
i am doing simple application.i am getting some problems with getting data from my java class.can you suggest me any ideas1) table Employee
—empno
—empname
—salary
2)i created project with this tablein my java class i created
Employee emp=new Employee();
i cant get these properties with Employee.setEmpno();
emp.setEmpno();
emp.setEmpname();
emp.setEmpsalary();how i can get these properties in java class?
artifacts creating two classes
1)Employee—i cant get accessor methods in this class
2)Employeeid —-i dont know what it is
how i can get properties with in employee and how i can get those properties in the
application .java file i mean above mention employee table like code.plZ suggest me your valuable suggestions i stucked up here.i am a new user with eclise with hibernate.
by
j.sunilkumar
Loyal WaterMemberj.sunilkumar,
You need to use a getter to retrieve the value. You seem to using a setter. I would suggest you go through a Java tutorial to understand how to user getters and setters.
jaladanki_sunilMemberthanks for your good response my problem is Aftergenenerating artifacts two classes are produced by the eclipse
those are
1)Employee
2)EmployeeID
if i wirte .java file on that package explorer then how i can set the values through Employee class or EmployeeId.
plz suggest if any tutorials. i did not understand about configuration in eclipse tutorials plz.if i create Employee emp=new Employee() —–>in this class eclipse not defined setters and gettters only empid related methods are defined.
if i create Employeeid empid=new EmployeeId()—>then i am gettig error is displaying that invalid employeeid entity.how i can set values from which object .what is wrong in my code.this is simple but by defalut eclipse giving two classes.
anyconfiguration data is wrong?
i am following this tutorial but i cant understand this figure description
https://www.genuitec.com/forums/topics/myeclipse/
for this code i am getting error
MessagesId message=new MessagesId();
message.setMessageId(new Long(11));
message.setMessageText(“ssss”);
message.setNextMessageId(new Long(22));session.save(message);
log4j:WARN Please initialize the log4j system properly.
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: component class not found: MessagesId at org.hibernate.mapping.Component.getComponentClass(Component.java:105)
at org.hibernate.tuple.PojoComponentTuplizer.buildGetter(PojoComponentTuplizer.java:155)
at org.hibernate.tuple.AbstractComponentTuplizer.<init>(AbstractComponentTuplizer.java:40)
at org.hibernate.tuple.PojoComponentTuplizer.<init>(PojoComponentTuplizer.java:43)
at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:126)
at org.hibernate.mapping.Component.getType(Component.java:160)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.RootClass.validate(RootClass.java:193)
at org.hibernate.cfg.Configuration.validate(Configuration.java:984)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1169)
at abc.sun.Hibsessionfactory.<clinit>(Hibsessionfactory.java:31)
at abc.sun.Apptwo.main(Apptwo.java:13)
Caused by: java.lang.ClassNotFoundException: MessagesId
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:272)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:140)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.mapping.Component.getComponentClass(Component.java:102)
… 11 more
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: Could not read mappings from resource: abc/sun/Messages.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:485)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at abc.sun.Hibsessionfactory.rebuildSessionFactory(Hibsessionfactory.java:69)
at abc.sun.Hibsessionfactory.getSession(Hibsessionfactory.java:53)
at abc.sun.Apptwo.main(Apptwo.java:13)
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping abc.sun.Messages
at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:154)
at org.hibernate.cfg.Configuration.add(Configuration.java:386)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:427)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:482)
… 8 more
java.lang.NullPointerException
at abc.sun.Apptwo.main(Apptwo.java:15)
Exception in thread “main”
jaladanki_sunilMemberplz other wise good demo using eclipse on hibernate link plz
jaladanki_sunilMembersorry dudes i got solution that is i made a big mistake when creating table i didn’t specify the primary key.
for hibernate we should create table with primary key am i correct?i got the results aftercreation of the table with primary key
Loyal WaterMemberGlad you got the result you were looking for.
-
AuthorPosts