Rathan Chanti

Greenhorn
+ Follow
since Apr 12, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rathan Chanti

I am getting duplicate Http requests for all the controllers and services. The following is one of the service I have created using ionic. I am not getting what's causing duplicate request in my code.

**login.html**



**app.js**

 

**contoller**



**service**
Redirecting bounced email is not working for me even after I tried with various ports (587, 465, and 25 ), SMTP Servers (smtp.gmail.com, smtp.live.com, and smtp.mail.yahoo.com ), Message objects (MimeMessage, Message, and SMTPMessage), and JavaMail API methods (message.addFrom, message,setReplyTo, and message.setHeader). I also tried to change javax.mail jar versions 1.4, 1.5 and etc. Everywhere in the stackoverflow they are saying, setting the other email to mail.smtp.from should work. But all my bounced emails are going back to sender. Not to the specified email address. Can someone help me to redirect it to a new email address? Here is the code I am using
7 years ago

William P O'Sullivan wrote:Great to hear...

You may have to talk to the DBAs or issue GRANTs.

If not, then your hibernate may have a missing parameter.
I see the "create" in your config. Maybe it needs something else.

I personally never create db entities unless in a test/dev/in-memory mode.
Too many problems can occur, and I want to control my DB.

WP



I tried like "<property name="hbm2.ddl.auto">update</property>"
But still the hibernate couldn't create a table by itself.

William P O'Sullivan wrote:Well of course you will not be able to insert into a table that does not exist.

Also beware that the schema used may default to your own userid, if you do not provide one.

As for the application not being able to create the table, that could be permissions and authorities.

Our enterprise apps can CRUD all day long but cannot Alter or create any DB entities.

WP



Yes, I just manually created the table and executed the program again. The data has been inserted. Great!
But is there any way you can tell me how to give permissions to hibernate to create the table ??

Anurag Verma wrote:can you provide or verify your database configurations are correct & the database and table exists?



Here are my configurations in xml file...hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory
name="java:hibernate/SessionFactory">
<!-- properties -->
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
<property name="connection.username">system</property>
<property name="connection.password">srirama</property>
<property name="connection.autocommit">true</property>
<property name="connection.pool_size">1</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<!-- <property name="dialect">org.hibernate.dialect.OracleDialect</property> -->
<property name="show_sql">true</property>
<property name="hbm2.ddl.auto">create</property>
<!-- mapping files -->
<mapping class="org.rathan.dto.UserDetails"/>
</session-factory>
</hibernate-configuration>

Sumit Bisht wrote:

Rathan Kamireddy wrote:
Caused by: java.sql.BatchUpdateException: ORA-00942: table or view does not exist


Can you confirm the presence of the table ?
Also, please try querying without using hibernate (from console/ using jdbc)



I checked in the oracle database. There is no table with the same name. Even the program couldn't even create the new table dude.. it is lil frustrating...
While I tried to execute my hibernate with oracle xe I got the following error.
Hibernate: insert into USER_DETAILS (data, mydate, phonenumber, USER_NAME, USER_ID) values (?, ?, ?, ?, ?)
Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:268)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)
at org.rathan.dto.Test.main(Test.java:31)
Caused by: java.sql.BatchUpdateException: ORA-00942: table or view does not exist

at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:367)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:9119)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)



Here is my UserDetails.java

package org.rathan.dto;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

@Entity
@Table (name="USER_DETAILS")
public class UserDetails {
@Id
@Column (name="USER_ID")
private int userid;
@Column (name="USER_NAME")
private String username;
@Transient
private String Address;
private static long salary;
private String phonenumber;
@Lob
private String data;
@Temporal (TemporalType.DATE)
private Date mydate;

public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}

public Date getMydate() {
return mydate;
}
public void setMydate(Date mydate) {
this.mydate = mydate;
}
public String getAddress() {
return Address;
}
public void setAddress(String address) {
Address = address;
}
public static long getSalary() {
return salary;
}
public static void setSalary(long salary) {
UserDetails.salary = salary;
}
public String getPhonenumber() {
return phonenumber;
}
public void setPhonenumber(String phonenumber) {
this.phonenumber = phonenumber;
}
public int getUserid() {
return userid;
}
public void setUserid(int userid) {
this.userid = userid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}

Here is my Test.java

package org.rathan.dto;

import java.util.Date;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class Test {

public static void main(String[] args) {
System.out.println(1);
UserDetails user=new UserDetails();
System.out.println(2);
user.setUserid(100);
user.setUsername("Rathan");
//user.setSalary(10000);
user.setPhonenumber("9989242487");
user.setAddress("My Home address");
user.setData("blah....blah....blah....blah....blah....");
user.setMydate(new Date());
System.out.println(3);
SessionFactory factory=new Configuration().configure().buildSessionFactory();
System.out.println(4);
Session session=factory.openSession();
System.out.println(5);
session.beginTransaction();
System.out.println(6);
session.save(user);
System.out.println(7);
session.getTransaction().commit();
System.out.println(8);
session.close();
/*user=null;
session=factory.openSession();
session.beginTransaction();
user=(UserDetails)session.get(UserDetails.class, 100);
System.out.println("The Retrieved details are: "+user.getUsername());*/
}
}

I added jdbc14.jar. And all jars from 'required' and 'jpa' folder of hibernate3.6.4 .