Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7769005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:03:49+00:00 2026-06-01T16:03:49+00:00

I am writing the following custom serializable UserType: public class SerUserType extends MutableUserType {

  • 0

I am writing the following custom serializable UserType:

public class SerUserType extends MutableUserType {
    protected Class klass;
    protected SerA ser=F.g(SerA.class);
    public Class returnedClass() {
        return klass;
    }
    public int[] sqlTypes() {
        return new int[] {Types.BLOB};
    }
    public boolean equals(Object x, Object y) throws HibernateException {
        return ObjectUtils.equals(x, y);
    }
    public Object deepCopy(Object value) {
        klass=value.getClass();
        Copyable copyable=(Copyable)value;
        Object copy=copyable.copy();
        return copy;
    }
    public Object nullSafeGet(ResultSet resultSet,String[] names,SessionImplementor session,Object owner) 
        throws HibernateException,SQLException {
        byte[] b=(byte[])BlobType.INSTANCE.nullSafeGet(resultSet,names,session,owner);
        return ser.deser(b,klass);
    }
    public void nullSafeSet(PreparedStatement preparedStatement,Object value,int index,SessionImplementor session) 
        throws HibernateException,SQLException {
        BlobType.INSTANCE.nullSafeSet(preparedStatement,ser.ser(value),index,session);
    }
}

I might even override the registered serialable class with it. In case you’re interested, the implementation of SerA is the protostuff serializer.

Anyway, it doesn’t appear that any of the methods providing the object in this interface are called before nullSafeGet so it is impossible to determine the class of the object we’re working with, making it impossible to obtain the class for the serialization call.

Therefore, it appears that the only solution is to make a ParameterizedType and pass the object’s class as a property. 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:03:50+00:00Added an answer on June 1, 2026 at 4:03 pm

    Unfortunately I believe that the only solution is to use a ParameterizedType and then create a type definition every time you want to use it with a different Class.

    If you need an example, see the code in this question:
    Hibernate Entities from Multiple Databases

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a custom web part that extends DataFormWebPart. public class MyCustomWebPart : DataFormWebPart{
I have the following custom iterator: class PetIterator<T extends Pet> implements Iterator<T> I have
I'm writing an MVC2 app using DataAnnotations. I have a following Model: public class
I am writing a custom .pac script for use with Firefox. Following numerous examples
I got tired of writing the following code: /* Commenting out irrelevant parts public
Following the example of writing a custom django-admin command here , I've created the
I'm writing a custom structure manipulation program, and I've got the following types: type
I'm new to writing custom ASP.NET server controls, and I'm encountering the following issue:
I am writing a custom NSView subclass. I have several instances of this class
I'm writing the iterator classes for a custom container (some hash map class), let's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.