SAP HANA
Installation​
TypeORM relies on @sap/hana-client for establishing the database connection:
npm install @sap/hana-client
If you are using TypeORM 0.3.25 or earlier, hdb-pool is also required for managing the pool.
Data Source Options​
See Data Source Options for the common data source options.
host- The hostname of the SAP HANA server. For example,"localhost".port- The port number of the SAP HANA server. For example,30015.username- The username to connect to the SAP HANA server. For example,"SYSTEM".password- The password to connect to the SAP HANA server. For example,"password".database- The name of the database to connect to. For example,"HXE".encrypt- Whether to encrypt the connection. For example,true.sslValidateCertificate- Whether to validate the SSL certificate. For example,true.key,certandca- Private key, public certificate and certificate authority for the encrypted connection.pool— Connection pool configuration object:maxConnectedOrPooled(number) — Max active or idle connections in the pool (default: 10).maxPooledIdleTime(seconds) — Time before an idle connection is closed (default: 30).pingCheck(boolean) — Whether to validate connections before use (default: false).poolCapacity(number) — Maximum number of connections to be kept available (default: no limit).
See the official documentation of SAP HANA Client for more details as well as the extra properties: Node.js Connection Properties.
Column Types​
SAP HANA 2.0 and SAP HANA Cloud support slightly different data types. Check the SAP Help pages for more information:
TypeORM's SapDriver supports tinyint, smallint, integer, bigint, smalldecimal, decimal, real, double, date, time, seconddate, timestamp, boolean, char, nchar, varchar, nvarchar, text, alphanum, shorttext, array, varbinary, blob, clob, nclob, st_geometry, st_point, real_vector, half_vector, vector, and halfvec. Some of these data types have been deprecated or removed in SAP HANA Cloud, and will be converted to the closest available alternative when connected to a Cloud database.
Vector Types​
The real_vector and half_vector data types were introduced in SAP HANA Cloud (2024Q1 and 2025Q2 respectively), and require a supported version of @sap/hana-client as well.
For consistency with PostgreSQL's vector support, TypeORM also provides aliases:
vector(alias forreal_vector) - stores vectors as 4-byte floatshalfvec(alias forhalf_vector) - stores vectors as 2-byte floats for memory efficiency
@Entity()
export class Document {
@PrimaryGeneratedColumn()
id: number
// Using SAP HANA native type names
@Column("real_vector", { length: 1536 })
embedding: Buffer | number[]
@Column("half_vector", { length: 768 })
reduced_embedding: Buffer | number[]
// Using cross-database aliases (recommended)
@Column("vector", { length: 1536 })
universal_embedding: Buffer | number[]
@Column("halfvec", { length: 768 })
universal_reduced_embedding: Buffer | number[]
}
By default, the client will return a Buffer in the fvecs/hvecs format, which is more efficient. It is possible to let the driver convert the values to a number[] by adding { extra: { vectorOutputType: "Array" } } to the connection options. Check the SAP HANA Client documentation for more information about REAL_VECTOR or HALF_VECTOR.