You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alok Pathak <al...@gmail.com> on 2012/03/19 14:02:24 UTC

java.util.Date cannot be cast to java.sql.Date

I have an application in Wicket 1.4, where i am using JPA. I declared an
entity (Customer) with property *dob* of type *java.sql.Date*. 
Now i want to migrate that application in Wicket 1.5, When I submit the
registration form of the customer I get the exception: *java.util.Date
cannot be cast to java.sql.Date*
Kindly Help
Thanks 
Alok Pathak


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/java-util-Date-cannot-be-cast-to-java-sql-Date-tp4484703p4484703.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: java.util.Date cannot be cast to java.sql.Date

Posted by Alok Pathak <al...@gmail.com>.
Kindly Help

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/java-util-Date-cannot-be-cast-to-java-sql-Date-tp4484703p4498860.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: java.util.Date cannot be cast to java.sql.Date

Posted by Alok Pathak <al...@gmail.com>.
That is ok* Declare the dob field as:

@Temporal(TemporalType.Date)
private (java.util.)Date dob;
*

But why not this in wicket 1.4.
I am pasting my code
*Book.java
##########
	import java.sql.Date;
	...
	private Date publishDate;


META-INF/persistence.xml
########################
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
 <persistence-unit name="bookStorePersistence">
   <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
   <class>edu.shubit.eShop.bean.Book</class>
   <properties>
      	<property name="eclipselink.platform.class.name"
value="org.eclipse.persistence.platform.database.SQLAnywherePlatform"/>
   		<property name="eclipselink.jdbc.driver" value="org.sqlite.JDBC"/>
       	<property name="eclipselink.jdbc.url"
value="jdbc:sqlite:data/bookStoreDB"/>
        <property name="persistence.tools.weaving" value="false"/>
      	<property name="eclipselink.ddl-generation" value="create-tables"/>
        <property name="eclipselink.ddl-generation.output-mode"
value="database"/>
   </properties>  
 </persistence-unit>
</persistence>


BookUploadPage.java
###################
	Book book=new Book();
	...
	frm=new Form("bookUploadForm",new CompoundPropertyModel(book)){
		{
			add(txtDate=new TextField("publishDate"));
		}
		protected void onSubmit(){
			BeansManager.insertBook(book)){				
		}
	}
	

BeansManager.java
#################
	public static boolean insertBook(Book book) {
		JPA.em.getTransaction().begin();
		JPA.em.persist(book);
		JPA.em.getTransaction().commit();
		return true;
	}
	

*


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/java-util-Date-cannot-be-cast-to-java-sql-Date-tp4484703p4485118.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: java.util.Date cannot be cast to java.sql.Date

Posted by Bas Gooren <ba...@iswd.nl>.
Declare the dob field as:

@Temporal(TemporalType.Date)
private (java.util.)Date dob;

Op 19-3-2012 14:02, schreef Alok Pathak:
> I have an application in Wicket 1.4, where i am using JPA. I declared an
> entity (Customer) with property *dob* of type *java.sql.Date*.
> Now i want to migrate that application in Wicket 1.5, When I submit the
> registration form of the customer I get the exception: *java.util.Date
> cannot be cast to java.sql.Date*
> Kindly Help
> Thanks
> Alok Pathak
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/java-util-Date-cannot-be-cast-to-java-sql-Date-tp4484703p4484703.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

Re: java.util.Date cannot be cast to java.sql.Date

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Do you say that in 1.4 you didn't do any conversion between the two
types and it just worked ?
See Component#getConverter(Class) method.

On Mon, Mar 19, 2012 at 3:02 PM, Alok Pathak <al...@gmail.com> wrote:
> I have an application in Wicket 1.4, where i am using JPA. I declared an
> entity (Customer) with property *dob* of type *java.sql.Date*.
> Now i want to migrate that application in Wicket 1.5, When I submit the
> registration form of the customer I get the exception: *java.util.Date
> cannot be cast to java.sql.Date*
> Kindly Help
> Thanks
> Alok Pathak
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/java-util-Date-cannot-be-cast-to-java-sql-Date-tp4484703p4484703.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org