Upgrade from 2.9 to Kundera 2.11 issue

46 views
Skip to first unread message

Alaa Abu Zaghleh

unread,
May 8, 2014, 2:20:15 AM5/8/14
to kundera...@googlegroups.com
After I upgarte to 2.11 as you suggest to solve my order by issue.  I start getting this exception it is complettly in different part of the application

the table is defined as follows.

create table medias_by_id(
    type TEXT,
    id UUID ,
    title TEXT,
    description TEXT,
    pic_320X320 TEXT,
    pic_100X100 TEXT,
    pic_large TEXT,
    image_category UUID,
    user_id UUID,
    created_date BIGINT,
    like_count INT ,
    share_count INT,
    dislike_count INT,
    comment_count INT,
    view_count INT,
    rating FLOAT,
    rating_total FLOAT,
    number_of_raring INT,    
    video_file_name text,
    PRIMARY KEY(id)
) ;

and this is the java model for that table


import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.
XmlRootElement;

import com.audition.dao.model.key.ImagesByDateKey;
import com.impetus.kundera.index.IndexCollection;
import com.impetus.kundera.index.Index;

/**
 */
@Entity
@Table(name = "medias_by_id", schema = "auditionspace@auditionspace_pu")
//@IndexCollection(columns = { @Index(name = "created_by"), @Index(name = "image_category")})
@XmlRootElement(name = "imagesById")
public class ImagesById {
    @Id

    @Column(name="id")
    private UUID id ;
    @Column(name="type")
    private String type ;
    @Column(name="created_date")
    private long createdDate ;

    @Column(name="user_id")
    private UUID userId ;
    @Column(name="description")
    private String description ;
    @Column(name="pic_320x320")
    private String pic320X320 ;
    @Column(name="pic_100x100")
    private String pic100X100 ;
    @Column(name="pic_large")
    private String picLarge ;
    @Column(name="image_category")
    private UUID imageCategory ;
    @Column(name="like_count")
    private int likeCount ;
    @Column(name="share_count")
    private int shareCount ;
    @Column(name="dislike_count")
    private int dislikeCount ;
    @Column(name="rating")
    private float rating ;
    @Column(name="rating_total")
    private float raingTotal ;
    @Column(name="number_of_raring")
    private int numberOfRating ;
    @Column(name="title")
    private String title;
    @Column(name="comment_count")
    private int commentCount ;
    @Column(name="view_count")
    private int viewCount ;
    @Column(name="video_file_name")
    private String videoFileName;
   
    /**
     * Method getUserId.
     * @return UUID
     */

    public UUID getUserId() {
        return userId;
    }
    /**
     * Method setUserId.
     * @param userId UUID
     */

    public void setUserId(UUID userId) {
        this.userId = userId;
    }
    /**
     * Method getDescription.
     * @return String
     */
    public String getDescription() {
        return description;
    }
    /**
     * Method setDescription.
     * @param description String
     */
    public void setDescription(String description) {
        this.description = description;
    }
    /**
     * Method getPic320X320.
     * @return String
     */
    public String getPic320X320() {
        return pic320X320;
    }
    /**
     * Method setPic320X320.
     * @param pic320x320 String
     */
    public void setPic320X320(String pic320x320) {
        pic320X320 = pic320x320;
    }
    /**
     * Method getPic100X100.
     * @return String
     */
    public String getPic100X100() {
        return pic100X100;
    }
    /**
     * Method setPic100X100.
     * @param pic100x100 String
     */
    public void setPic100X100(String pic100x100) {
        pic100X100 = pic100x100;
    }
    /**
     * Method getPicLarge.
     * @return String
     */
    public String getPicLarge() {
        return picLarge;
    }
    /**
     * Method setPicLarge.
     * @param picLarge String
     */
    public void setPicLarge(String picLarge) {
        this.picLarge = picLarge;
    }
    /**
     * Method getImageCategory.
     * @return UUID
     */
    public UUID getImageCategory() {
        return imageCategory;
    }
    /**
     * Method setImageCategory.
     * @param imageCategory UUID
     */
    public void setImageCategory(UUID imageCategory) {
        this.imageCategory = imageCategory;
    }
    /**
     * Method getLikeCount.
     * @return int
     */
    public int getLikeCount() {
        return likeCount;
    }
    /**
     * Method setLikeCount.
     * @param likeCount int
     */
    public void setLikeCount(int likeCount) {
        this.likeCount = likeCount;
    }
    /**
     * Method getShareCount.
     * @return int
     */
    public int getShareCount() {
        return shareCount;
    }
    /**
     * Method setShareCount.
     * @param shareCount int
     */
    public void setShareCount(int shareCount) {
        this.shareCount = shareCount;
    }
    /**
     * Method getDislikeCount.
     * @return int
     */
    public int getDislikeCount() {
        return dislikeCount;
    }
    /**
     * Method setDislikeCount.
     * @param dislikeCount int
     */
    public void setDislikeCount(int dislikeCount) {
        this.dislikeCount = dislikeCount;
    }
    /**
     * Method getRating.
     * @return float
     */
    public float getRating() {
        return rating;
    }
    /**
     * Method setRating.
     * @param rating float
     */
    public void setRating(float rating) {
        this.rating = rating;
    }
    /**
     * Method getRaingTotal.
     * @return float
     */
    public float getRaingTotal() {
        return raingTotal;
    }
    /**
     * Method setRaingTotal.
     * @param raingTotal float
     */
    public void setRaingTotal(float raingTotal) {
        this.raingTotal = raingTotal;
    }
    /**
     * Method getNumberOfRating.
     * @return int
     */
    public int getNumberOfRating() {
        return numberOfRating;
    }
    /**
     * Method setNumberOfRating.
     * @param numberOfRating int
     */
    public void setNumberOfRating(int numberOfRating) {
        this.numberOfRating = numberOfRating;
    }
    /**
     * Method getTitle.
     * @return String
     */
    public String getTitle() {
        return title;
    }
    /**
     * Method setTitle.
     * @param title String
     */
    public void setTitle(String title) {
        this.title = title;
    }
    /**
     * Method getId.
     * @return UUID
     */

    public UUID getId() {
        return id;
    }
    /**
     * Method setId.
     * @param id UUID
     */

    public void setId(UUID id) {
        this.id = id;
    }
    /**
     * Method getCommentCount.
     * @return int
     */
    public int getCommentCount() {
        return commentCount;
    }
    /**
     * Method setCommentCount.
     * @param commentCount int
     */
    public void setCommentCount(int commentCount) {
        this.commentCount = commentCount;
    }
    /**
     * Method getViewCount.
     * @return int
     */
    public int getViewCount() {
        return viewCount;
    }
    /**
     * Method setViewCount.
     * @param viewCount int
     */
    public void setViewCount(int viewCount) {
        this.viewCount = viewCount;
    }
    /**
     * Method getType.
     * @return String
     */
    public String getType() {
        return type;
    }
    /**
     * Method setType.
     * @param type String
     */
    public void setType(String type) {
        this.type = type;
    }
    /**
     * Method getCreatedDate.
     * @return long
     */
    public long getCreatedDate() {
        return createdDate;
    }
    /**
     * Method setCreatedDate.
     * @param createdDate long
     */
    public void setCreatedDate(long createdDate) {
        this.createdDate = createdDate;
    }
    /**
     * Method VideoFileName.
     * @return String
     */
    public String getVideoFileName() {
        return videoFileName;
    }
    /**
     * Method VideoFileName.
     * @param videoFileName String
     */
    public void setVideoFileName(String videoFileName) {
        this.videoFileName = videoFileName;
    }
}


and this is how I get the data based on the id

@Override
    public ImageDto getOneImageById(UUID id) {

        // TODO Auto-generated method stub
        String query = "SELECT images FROM " + ImagesById.class.getSimpleName()
                + " images WHERE images.id= :id";

        List<ImagesById> ls = (List<ImagesById>) this.dao.findByQuery(query,
                "id", id);

        if (ls != null && ls.size() > 0) {
            ImageDto dto = new ImageDto();
            dto = this.convertImagesByIdToImageDto(ls.get(0), dto);
            UserDto user = this.userBo.getUserById(dto.getUserId());
            String userFirstName = user.getFirstName();
            String userLastName = user.getLastName();
            MediaCategoriesDto category = this.imageCategorybo
                    .getImageCategoryById(dto.getImageCategory());
            String categoryName = category.getCategoryDesc();
            dto.setCategoryName(categoryName);
            dto.setUserFirstName(userFirstName);
            dto.setUserLastName(userLastName);
            return dto;
        } else {
            return null;
        }
    }

the bold line is where my code is broking currently it was working fine in 2.9. (5b997526-5485-4ef9-94b2-f261daa53eea) is there in the table I can select it using CQLSH. I dont know what casuing this issue, any help will be highly appreciated.



[Request processing failed; nested exception is javax.persistence.PersistenceException: javax.persistence.PersistenceException: com.impetus.kundera.KunderaException: InvalidRequestException(why:Undefined name key in where clause ('key EQ token(5b997526-5485-4ef9-94b2-f261daa53eea)'))] with root cause
InvalidRequestException(why:Undefined name key in where clause ('key EQ token(5b997526-5485-4ef9-94b2-f261daa53eea)'))

    at org.apache.cassandra.thrift.Cassandra$execute_cql3_query_result.read(Cassandra.java:37849)
    at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
    at org.apache.cassandra.thrift.Cassandra$Client.recv_execute_cql3_query(Cassandra.java:1562)
    at org.apache.cassandra.thrift.Cassandra$Client.execute_cql3_query(Cassandra.java:1547)
    at com.impetus.client.cassandra.CassandraClientBase.execute(CassandraClientBase.java:2291)
    at com.impetus.client.cassandra.CassandraClientBase.executeCQLQuery(CassandraClientBase.java:1860)
    at com.impetus.client.cassandra.CassandraClientBase$CQLClient.executeQuery(CassandraClientBase.java:2028)
    at com.impetus.client.cassandra.CassandraClientBase.executeSelectQuery(CassandraClientBase.java:854)
    at com.impetus.client.cassandra.thrift.ThriftClient.executeQuery(ThriftClient.java:906)
    at com.impetus.client.cassandra.query.CassQuery.populateEntities(CassQuery.java:135)
    at com.impetus.kundera.query.QueryImpl.fetch(QueryImpl.java:927)
    at com.impetus.kundera.query.QueryImpl.getResultList(QueryImpl.java:157)
    at com.audition.dao.impl.AuditionDaoImpl.findByQuery(AuditionDaoImpl.java:143)
    at com.audition.bo.impl.ImageBoImpl.getOneImageById(ImageBoImpl.java:520)
    at com.audition.bo.impl.UserActivityBoImpl.getUserActivityByUserAndHisFriend(UserActivityBoImpl.java:111)

Vivek Mishra

unread,
May 8, 2014, 2:26:31 AM5/8/14
to kundera...@googlegroups.com
I am looking at it and will soon post an update.

-Vivek

From: kundera...@googlegroups.com <kundera...@googlegroups.com> on behalf of Alaa Abu Zaghleh <alaa.ab...@gmail.com>
Sent: 08 May 2014 11:50
To: kundera...@googlegroups.com
Subject: {kundera-discuss} Upgrade from 2.9 to Kundera 2.11 issue
 
--
You received this message because you are subscribed to the Google Groups "kundera-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kundera-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.








NOTE: This message may contain information that is confidential, proprietary, privileged or otherwise protected by law. The message is intended solely for the named addressee. If received in error, please destroy and notify the sender. Any use of this email is prohibited when received in error. Impetus does not represent, warrant and/or guarantee, that the integrity of this communication has been maintained nor that the communication is free of errors, virus, interception or interference.

Vivek Mishra

unread,
May 8, 2014, 3:10:57 AM5/8/14
to kundera...@googlegroups.com
Can you please share Dao implementation and persistence.xml?

-Vivek

From: kundera...@googlegroups.com <kundera...@googlegroups.com> on behalf of Alaa Abu Zaghleh <alaa.ab...@gmail.com>
Sent: 08 May 2014 11:50
To: kundera...@googlegroups.com
Subject: {kundera-discuss} Upgrade from 2.9 to Kundera 2.11 issue
 
--
You received this message because you are subscribed to the Google Groups "kundera-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kundera-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kuldeep Mishra

unread,
May 8, 2014, 3:49:49 AM5/8/14
to kundera...@googlegroups.com
Use kundera-cassandra in cql3 way. Do the following while creating EntityManagerFactory.
 Map<String, String> propertyMap = new HashMap<String, String>();
 propertyMap.put(CassandraConstants.CQL_VERSION, CassandraConstants.CQL_VERSION_3_0);

 EntityManagerFactory emf = Persistence.createEntityManagerFactory("pu-name", propertyMap);

Hope it will work for you.

--
Thanks and Regards
Kuldeep Kumar Mishra
+919540965199

Alaa Abu Zaghleh

unread,
May 8, 2014, 12:01:15 PM5/8/14
to kundera...@googlegroups.com
this is my persistence

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
    http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0">
    <persistence-unit name="auditionspace_pu">
        <provider>com.impetus.kundera.KunderaPersistence</provider>
        <class>com.audition.dao.model.Poc</class>
        <class>com.audition.dao.model.UsersByEmailPassword</class>
        <class>com.audition.dao.model.UserById</class>
        <class>com.audition.dao.model.MediaCategoriesSorted</class>
        <class>com.audition.dao.model.MediaCategoriesUnSorted</class>
        <class>com.audition.dao.model.ImagesByDate</class>
        <class>com.audition.dao.model.ImagesById</class>
        <class>com.audition.dao.model.ImagesByLike</class>
        <class>com.audition.dao.model.MediasComments</class>
        <class>com.audition.dao.model.MediasCommentsById</class>
        <class>com.audition.dao.model.UserFriendShipRequest</class>
        <class>com.audition.dao.model.UserFriendShipRequestById</class>
        <class>com.audition.dao.model.UserFriendShipRequestByBothUser</class>
        <class>com.audition.dao.model.UserFriendShip</class>
        <class>com.audition.dao.model.UserActivity</class>
        <class>com.audition.dao.model.UserActivityById</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
        <properties>
            <property name="kundera.nodes" value="localhost" />
            <property name="kundera.port" value="9160" />
            <property name="kundera.keyspace" value="auditionspace" />
            <property name="kundera.dialect" value="cassandra" />
<!--             <property name="kundera.ddl.auto.prepare" value="create" /> -->
            <property name="kundera.client" value="thrift" />
            <property name="kundera.client.lookup.class"
                value="com.impetus.client.cassandra.thrift.ThriftClientFactory" />
            <!--  <property name="kundera.cache.provider.class"
                value="com.impetus.kundera.cache.ehcache.EhCacheProvider" />
            <property name="kundera.cache.config.resource" value="/ehcache-test.xml" />-->
        </properties>
    </persistence-unit>
</persistence>   
this is the dao impl
package com.audition.dao.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import javax.persistence.PersistenceProperty;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;


import com.audition.dao.AuditionDao;
import com.impetus.client.cassandra.common.CassandraConstants;


// @Transactional(propagation = Propagation.REQUIRED)
/**
 */
@Repository("auditionDao")
public class AuditionDaoImpl implements AuditionDao
{
    /**
* logger used for logging statement.
*/
    //private static final Logger log = LoggerFactory.getLogger(AuditionDaoImpl.class);

    @PersistenceContext(unitName = "auditionspace_pu", type = PersistenceContextType.EXTENDED ,
             properties = {
            @PersistenceProperty
            (
                    name = CassandraConstants.CQL_VERSION, value=CassandraConstants.CQL_VERSION_3_0
            )
    })
    private EntityManager em;

    public AuditionDaoImpl()
    {
    }

    /**
     * Method insert.
     * @param entity Object
     * @see com.audition.dao.AuditionDao#insert(Object)
     */
    @Override
    public void insert(Object entity)
    {
        em.persist(entity);
        em.clear();
    }

    /**
     * Method merge.
     * @param entity Object
     * @see com.audition.dao.AuditionDao#merge(Object)
     */
    @Override
    public void merge(Object entity)
    {
        em.merge(entity);
        em.clear();
    }

    /**
     * Method remove.
     * @param entity Object
     * @see com.audition.dao.AuditionDao#remove(Object)
     */
    @Override
    public void remove(Object entity)
    {
        em.remove(entity);
        em.clear();
    }

    /**
     * Method findById.
     * @param entityClazz Class<T>
     * @param id Object
     * @return T
     * @see com.audition.dao.AuditionDao#findById(Class<T>, Object)
     */
    @Override
    public <T> T findById(Class<T> entityClazz, Object id)
    {
        T results = em.find(entityClazz, id);
        return results;
    }

    /**
     * Method findByQuery.
     * @param queryString String
     * @return List<?>
     * @see com.audition.dao.AuditionDao#findByQuery(String)
     */
    @Override
    public List<?> findByQuery(String queryString)
    {
        System.out.println(queryString);
        Query query = em.createQuery(queryString);
        List<?> resultList = query.getResultList();
        System.out.println("Number Of Pocs in DB Is " + resultList.size()) ;//this show 0 as I send it in the previous post
        return resultList;
    }
   
    /**
     * Method findByQuery.
     * @param queryString String
     * @param count int
     * @return List<?>
     * @see com.audition.dao.AuditionDao#findByQuery(String, int)
     */
    @Override
    public List<?> findByQuery(String queryString , int count)
    {
        try{
        Query query = em.createQuery(queryString);
        query.setMaxResults(count) ;
        List<?> resultList = query.getResultList();
        return resultList;
        }catch(Exception exp){
            exp.printStackTrace();
        }
       
        return null ;
    }

    /**
     * Method findByQuery.
     * @param queryString String
     * @param paramater String
     * @param parameterValue Object
     * @return List<?>
     * @see com.audition.dao.AuditionDao#findByQuery(String, String, Object)
     */
    @Override
    public List<?> findByQuery(String queryString, String paramater, Object parameterValue)
    {
        Query query = em.createQuery(queryString);
        query.setParameter(paramater, parameterValue);
        System.out.println(queryString);
        List<?> resultList = query.getResultList();
        return resultList;
    }
   
    /**
     * Method findByQuery.
     * @param queryString String
     * @param paramater String[]
     * @param parameterValue Object[]
     * @return List<?>
     * @see com.audition.dao.AuditionDao#findByQuery(String, String[], Object[])
     */
    @Override
    public List<?> findByQuery(String queryString, String[] paramater, Object[] parameterValue)
    {
        System.out.println(queryString + " =====================>>") ;
        Query query = em.createQuery(queryString);
      
        for(int i=0; i<paramater.length; i++){
        query.setParameter(paramater[i], parameterValue[i]);
        }
       
        System.out.println(queryString);
        List<?> resultList = query.getResultList();
        return resultList;
    }
   
    /**
     * Method findByQuery.
     * @param queryString String
     * @param paramater String[]
     * @param parameterValue Object[]
     * @param count int
     * @return List<?>
     * @see com.audition.dao.AuditionDao#findByQuery(String, String[], Object[], int)
     */
    @Override
    public List<?> findByQuery(String queryString, String[] paramater, Object[] parameterValue , int count)
    {
        Query query = em.createQuery(queryString);
        for(int i=0; i<paramater.length; i++){
        query.setParameter(paramater[i], parameterValue[i]);
        } 
        query.setMaxResults(count) ;
        List<?> resultList = query.getResultList();
        return resultList;
    }

    /**
     * Method getEntityManager.
     * @return EntityManager
     * @see com.audition.dao.AuditionDao#getEntityManager()
     */
    @Override
    public EntityManager getEntityManager()
    {
        return em;
    }

    /**
     * Method closeEntityManager.
     * @see com.audition.dao.AuditionDao#closeEntityManager()
     */
    @Override
    public void closeEntityManager()
    {
        if (em != null)
        {
            em.close();
        }
    }

    /**
     * Method clearEntityManager.
     * @see com.audition.dao.AuditionDao#clearEntityManager()
     */
    @Override
    public void clearEntityManager()
    {
        if (em != null)
        {
            em.clear();
        }
    }

    /**
     * Method shutDown.
     * @see com.audition.dao.AuditionDao#shutDown()
     */
    @Override
    public void shutDown()
    {
        if (em != null)
        {
            em.close();
        }
    }
}

and this is how I create the persistence in spring

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"
    default-autowire="byName">

    <tx:annotation-driven />

    <!-- Scans within the base package of the application for @Components to
        configure as beans -->
    <context:component-scan base-package="com.audition.dao" />

    <bean id="emf-p1"
        class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="persistenceUnitName" value="auditionspace_pu" />
        <property name="loadTimeWeaver">
            <bean
                class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
        </property>
    </bean>


    <bean
        class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor">
    </bean>

<!--     <bean id="pum" -->
<!--         class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager"> -->
<!--         <property name="persistenceXmlLocations"> -->
<!--             <list> -->
<!--                 <value>META-INF/persistence.xml</value> -->
<!--             </list> -->
<!--         </property> -->
<!--     </bean> -->

    <bean id="matchAllWithPropReq"
        class="org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource">
        <property name="transactionAttribute" value="PROPAGATION_REQUIRED" />
    </bean>

</beans>

Alaa Abu Zaghleh

unread,
May 12, 2014, 4:28:07 PM5/12/14
to kundera...@googlegroups.com
No Update on this issue

On Thursday, May 8, 2014 1:20:15 AM UTC-5, Alaa Abu Zaghleh wrote:

Chhavi Gangwal

unread,
May 13, 2014, 1:39:55 AM5/13/14
to kundera...@googlegroups.com
Hi Alaa,

Confirming this is an issue with Kundera 2.11 .We are working on fixing it in trunk and will update you once fixed.

Chhavi
Message has been deleted

Chhavi Gangwal

unread,
May 15, 2014, 5:29:56 AM5/15/14
to kundera...@googlegroups.com
A fix for the issue has been added in current trunk . Please verify.


Chhavi
Reply all
Reply to author
Forward
0 new messages