2

Is it possible/practical to have an Entity class without an underlying database available?

To contradict myself, I have a database(!) which can be accessed over jdbc, but it's proprietary and only supports a couple of methods - connect/disconnect/execute - no schema browsing, no metadata, or connecting through a tool - only code.

What I'd like to do is create a set of restful web services that access the database & those appear to need underlying Entity classes based on the database.

So, my question is if this is the right way to handle this situation? I'm reasonably new to these technologies so am probably struggling with design issues more - any articles I can read up on how to approach this would be great.

Many thanks

KarlP
  • 309
  • 3
  • 15

2 Answers2

1

Restful web services in general don't have to be based on accessing database through entities. You might have seen it in various examples, but JPA and web services are totally independent technologies.

In the situation you describe, using entities does not seem reasonable, or even possible. It depends on how this proprietary JDBC driver is implemented - and from what you've said, it's not a full implementation.

MaDa
  • 10,511
  • 9
  • 46
  • 84
0
  1. The only requirement to create an Entity class is 'You should know the existing Table DB schema'.
TableName: Sample
A : number
B : VARCHAR2(300)

Entity
@TableName..
Public Sample{
@Column..
int A;
@Column..
String B:
}

But what I would suggest you is check whether your Database supports JPA Hibernate.

-->REST service to perform the Database operations is perfectly okay to proceed.

Dinesh
  • 1,088
  • 4
  • 16
  • 28
  • The database won't support JPA Hibernate unfortunately. It's an in memory db & also the schema is dynamic (there is a base schema that is always extended by users & even the base get's modified at some sites). I'm leaning towards sticking with REST - I've got enough classes already that sufficiently abstract me from that deal with the vagaries of the db so I think a rest controller into my existing classes may just do the job. – KarlP Sep 12 '12 at 09:05
  • when you have sufficient existing classes, then you can expose those as a REST methods to perform basic operations over database. – Dinesh Sep 12 '12 at 09:25